示例#1
0
    public bool AddUndirectedEdge(T from, T to)
    {
        bool          result   = false;
        GraphNode <T> fromNode = nodeSet.FindByValue(from) as GraphNode <T>;
        GraphNode <T> toNode   = nodeSet.FindByValue(to) as GraphNode <T>;

        if (fromNode != null && toNode != null)
        {
            result = true;
            AddUndirectedEdge(fromNode, toNode);
        }

        return(result);
    }
示例#2
0
 /// <summary>
 /// Adiciona uma aresta direcionada no grafo sem custo
 /// </summary>
 /// <param name="from"></param>
 /// <param name="to"></param>
 public void AddDirectedEdge(T from, T to, int d)
 {
     AddDirectedEdge(nodeSet.FindByValue(from), nodeSet.FindByValue(to), d);
 }
示例#3
0
 public void AddDirectedEdge(T from, T to)
 {
     nodeSet.FindByValue(from).Neighbors.Add(nodeSet.FindByValue(to));
 }
示例#4
0
 public bool Contains(T value)
 {
     return(nodeSet.FindByValue(value) != null);
 }
示例#5
0
 public void AddDirectedEdge(T from, T to, float cost)
 {
     AddDirectedEdge((GraphNode <T>)nodeSet.FindByValue(from), (GraphNode <T>)nodeSet.FindByValue(to), cost);
 }
示例#6
0
 /// <summary>
 /// Adds a directed edge from a GraphNode with one value (from) to a GraphNode with another value (to)
 /// with an associated cost.
 /// </summary>
 /// <param name="from">The value of the GraphNode from which the directed edge eminates.</param>
 /// <param name="to">The value of the GraphNode to which the edge leads.</param>
 /// <param name="cost">The cost of the edge from "from" to "to".</param>
 public void AddDirectedEdge(T from, T to, int cost)
 {
     ((GraphNode <T>)nodeSet.FindByValue(from)).Neighbors.Add(nodeSet.FindByValue(to));
     ((GraphNode <T>)nodeSet.FindByValue(from)).Costs.Add(cost);
 }