Exemplo n.º 1
0
        // For example, edges like (1, 2), (2, 3) => there's an edge between vertices 0 and 1 and 1 and 2.
        public static SimpleGraph CreateFromOneBasedEdges(int vertexCount, int[,] edges)
        {
            var graph = new SimpleGraph(vertexCount);

            for (int id = 0; id < vertexCount; ++id)
            {
                graph._vertices[id] = new Vertex(graph, id);
            }

            for (int i = 0; i < edges.GetLength(0); ++i)
            {
                graph.AddEdge(edges[i, 0] - 1, edges[i, 1] - 1);
            }

            return graph;
        }
Exemplo n.º 2
0
 internal Vertex(SimpleGraph graph, int ID)
 {
     _graph = graph;
     this.ID = ID;
 }