Exemple #1
0
        /// <summary>
        /// this will only work if both nodes are already in the graph, it won't! add them.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="value"></param>
        /// <returns>the edge if it is created, null otherwise</returns>
        public GraphEdge <T> createEdge(GraphNode <T> start, GraphNode <T> end, float value = 1)
        {
            if (start != null && end != null)
            {
                var edge = new GraphEdge <T>(start, end, value);
                start.AddEdgeTwoWay(edge);
                end.AddEdgeTwoWay(edge);
                _edges.Add(edge);
                return(edge);
            }

            return(null);
        }
Exemple #2
0
        /// <summary>
        /// this will only work if both values are already in the graph, it won't! add them.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="value"></param>
        /// <returns>the created edge, if it exist, otherwise null</returns>
        public GraphEdge <T> createEdge(T start, T end, float value = 1)
        {
            if (_nodes[start] != null && _nodes[end] != null)
            {
                var edge = new GraphEdge <T>(_nodes[start], _nodes[end], value);
                _nodes[start].AddEdgeTwoWay(edge);
                _nodes[end].AddEdgeTwoWay(edge);
                _edges.Add(edge);
                return(edge);
            }

            return(null);
        }