예제 #1
0
 /// <summary>
 /// Creates an adjacency instance for the <paramref name="graph"/>.
 /// It's optimized in comparison to creating adjacency directly from an actual <see cref="InducedSubgraph.Subgraph"/>
 /// of <paramref name="graph"/>.
 /// </summary>
 /// <param name="graph">Graph to create adjacency for.</param>
 /// <returns>Graph's adjacency.</returns>
 public static VertexAdjacency Adjacency(this InducedSubgraph graph) => new VertexAdjacency(graph);
예제 #2
0
 /// <summary>
 /// Calculates and creates adjacency for given graph. Optimized for induced subgraphs
 /// in comparison to <see cref="VertexAdjacency(Graph)"/>.
 /// </summary>
 /// <param name="subgraph">Graph to calculate vertex adjacency in.</param>
 public VertexAdjacency(InducedSubgraph subgraph)
 {
     Graph            = subgraph.Subgraph;
     IncidentEdges    = Graph.Vertices.ToImmutableSortedDictionary(v => v, v => subgraph.OriginalAdjacency.IncidentEdges[v].Except(subgraph.RemovedEdges));
     AdjacentVertices = CreateAdjacentVertices();
 }