public InducedSubgraph(VertexAdjacency adjacency, IEnumerable <Vertex> removedVertices) { OriginalGraph = adjacency.Graph; OriginalAdjacency = adjacency; RemovedVertices = removedVertices.ToImmutableSortedSet(); RemovedEdges = removedVertices.SelectMany(v => adjacency.IncidentEdges[v]).ToImmutableSortedSet(); var vertices = adjacency.Graph.Vertices.Except(RemovedVertices); var edges = adjacency.Graph.Edges.Except(RemovedEdges); Subgraph = new Graph(vertices, edges); }
public VertexDegrees(VertexAdjacency adjacency) { Degrees = adjacency.Graph.Vertices.ToImmutableSortedDictionary(v => v, v => v.Degree(adjacency)); }
public static InducedSubgraph InducedSubgraphByRemovingVertices(this VertexAdjacency adjacency, IEnumerable <Vertex> removedVertices) { return(new InducedSubgraph(adjacency, removedVertices)); }
/// <summary> /// Creates container for graph's vertex degrees. /// </summary> /// <param name="adjacency"></param> /// <returns></returns> public static VertexDegrees VertexDegrees(this VertexAdjacency adjacency) => new VertexDegrees(adjacency);
public static int Degree(this Vertex vertex, VertexAdjacency adjacency) => adjacency.AdjacentVertices[vertex].Count;
public static InducedSubgraph InducedSubgraph(this Graph graph, VertexAdjacency adjacency, ImmutableSortedSet <Vertex> vertices) { // old // new Graph(vertices.ToImmutableSortedSet(), graph.Edges.Where(e => e.IsInInduced(vertices)).ToImmutableSortedSet()) return(adjacency.InducedSubgraph(vertices)); }
public static InducedSubgraph InducedSubgraph(this VertexAdjacency adjacency, ImmutableSortedSet <Vertex> vertices) { return(new InducedSubgraph(adjacency, adjacency.Graph.Vertices.Except(vertices))); }
public static InducedSubgraph InducedSubgraphByRemovingVertices(this Graph graph, VertexAdjacency adjacency, IEnumerable <Vertex> removedVertices) { return(adjacency.InducedSubgraphByRemovingVertices(removedVertices)); }