示例#1
0
            internal WeightedDiGraphVertex(WeightedDiGraph <T, TW> graph, T vertexKey)
            {
                if (!graph.vertexIndices.ContainsKey(vertexKey))
                {
                    throw new ArgumentException("vertex is not in this graph.");
                }

                this.graph       = graph;
                this.vertexKey   = vertexKey;
                this.vertexIndex = graph.vertexIndices[vertexKey];
            }
示例#2
0
        public WeightedDiGraph <T, TW> Clone()
        {
            var graph = new WeightedDiGraph <T, TW>();

            foreach (var vertex in this)
            {
                graph.AddVertex(vertex);
            }

            foreach (var vertex in this)
            {
                foreach (var edge in OutEdges(vertex))
                {
                    graph.AddEdge(vertex, edge.Key, edge.Value);
                }
            }

            return(graph);
        }