Replace Vertex in Quickgraph (C#)

255 views Asked by At

I want to replace the value of an vertex of my BidirectionalGraph or the vertex itself. The graph itself should not change. That means all the edges that are connected to the vertex stay connected to the vertex after I change the value of it. I would be surprised if their was no easy way in quickgraph to approach it.

My code is very long, so I try to describe it with an example code.

    private class GraphValues
    {
        public int Index;
        public string Name;

        public GraphValues(string name, int index)
        {
            Name = name;
            Index = index;
        }
    }

    private BidirectionalGraph<GraphValues, Edge<GraphValues>> GenerateTestGraph()
    {
        BidirectionalGraph<GraphValues, Edge<GraphValues>> testGraph = new BidirectionalGraph<GraphValues, Edge<GraphValues>>();
        GraphValues A = new GraphValues("A", -1);
        GraphValues B = new GraphValues("B", -1);
        GraphValues C = new GraphValues("C", -1);
        GraphValues AB = new GraphValues("AB", -1);
        GraphValues ABC = new GraphValues("ABC", -1);

        testGraph.AddVerticesAndEdge(new Edge<GraphValues>(A, AB));
        testGraph.AddVerticesAndEdge(new Edge<GraphValues>(B, AB));
        testGraph.AddVerticesAndEdge(new Edge<GraphValues>(B, ABC));
        testGraph.AddVerticesAndEdge(new Edge<GraphValues>(AB, ABC));
        testGraph.AddVerticesAndEdge(new Edge<GraphValues>(C, ABC));

        return testGraph;
    }

The function GenerateTestGraph() here only generates a simple example graph. My aim is to change the index values of some vertex-values in the graph. So I wanna generate some function which changes the values of my graph. Is their an easy way to do this? Or did I have to regenerate the graph itself with the new indexes?

So I change this graph:
Inputgraph (example)

Into this one:
Outputgraph (example)

0

There are 0 answers