예제 #1
0
        public GraphEdge <T> CreateEdge(GraphVertex <T> origin, GraphVertex <T> destination, double weight = 1d)
        {
            var newEdge = new GraphEdge <T>(origin, destination, weight);

            this.edges.Add(newEdge);
            return(newEdge);
        }
예제 #2
0
        public GraphVertex <T> CreateVertex(T value)
        {
            var newVertex = new GraphVertex <T>(this, value);

            vertices.Add(newVertex);
            return(newVertex);
        }
        public GraphEdge(GraphVertex <T> origin, GraphVertex <T> destination, double weight)
        {
            if (origin == null)
            {
                throw new ArgumentNullException("origin");
            }

            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }

            if (!object.ReferenceEquals(origin.Graph, destination.Graph))
            {
                throw new ArgumentException("Both Vertices should belong to the same graph.");
            }

            this.Origin      = origin;
            this.Destination = destination;
            this.Weight      = weight;
        }
 public GraphEdge(GraphVertex <T> origin, GraphVertex <T> destination)
     : this(origin, destination, 1d)
 {
 }