Пример #1
0
        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);
        }
Пример #2
0
 public VertexDegrees(VertexAdjacency adjacency)
 {
     Degrees = adjacency.Graph.Vertices.ToImmutableSortedDictionary(v => v, v => v.Degree(adjacency));
 }
Пример #3
0
 public static InducedSubgraph InducedSubgraphByRemovingVertices(this VertexAdjacency adjacency, IEnumerable <Vertex> removedVertices)
 {
     return(new InducedSubgraph(adjacency, removedVertices));
 }
Пример #4
0
 /// <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);
Пример #5
0
 public static int Degree(this Vertex vertex, VertexAdjacency adjacency) => adjacency.AdjacentVertices[vertex].Count;
Пример #6
0
 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));
 }
Пример #7
0
 public static InducedSubgraph InducedSubgraph(this VertexAdjacency adjacency, ImmutableSortedSet <Vertex> vertices)
 {
     return(new InducedSubgraph(adjacency, adjacency.Graph.Vertices.Except(vertices)));
 }
Пример #8
0
 public static InducedSubgraph InducedSubgraphByRemovingVertices(this Graph graph, VertexAdjacency adjacency, IEnumerable <Vertex> removedVertices)
 {
     return(adjacency.InducedSubgraphByRemovingVertices(removedVertices));
 }