public override void AddEdge(IEdge e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("edge");
     }
     if (!this.VertexInEdges.ContainsKey(e.get_Source()))
     {
         throw new VertexNotFoundException("Could not find source vertex");
     }
     if (!this.VertexInEdges.ContainsKey(e.get_Target()))
     {
         throw new VertexNotFoundException("Could not find target vertex");
     }
     base.AddEdge(e);
     this.VertexInEdges.get_Item(e.get_Target()).Add(e);
 }
 protected void TraverseEdge(IEdge e, int i)
 {
     IVertex v = e.get_Source();
     IVertex vertex2 = e.get_Target();
     if (this.TestGraph.ContainsChoicePoint(v))
     {
         if (!this.newFront.Contains(v))
         {
             double num = 0.0;
             double num2 = 0.0;
             IEdgeEnumerator enumerator = this.TestGraph.Graph.OutEdges(v).GetEnumerator();
             while (enumerator.MoveNext())
             {
                 IEdge edge = enumerator.get_Current();
                 num += this.TestGraph.Prob(edge) * this.probs.get_Item(edge.get_Target()).get_Item(i - 1);
                 num2 += this.TestGraph.Cost(edge) + this.costs.get_Item(edge.get_Target()).get_Item(i - 1);
             }
             this.probs.get_Item(v).Add(num);
             this.costs.get_Item(v).Add(num2);
             this.newFront.Add(v);
         }
     }
     else if (this.Improving(e, i))
     {
         this.Strategy.SetChooseEdge(v, i, e);
         this.probs.get_Item(v).Add(this.probs.get_Item(vertex2).get_Item(i - 1));
         this.costs.get_Item(v).Add(this.TestGraph.Cost(e) + this.costs.get_Item(vertex2).get_Item(i - 1));
         this.newFront.Add(v);
     }
 }
 protected bool Improving(IEdge e, int i)
 {
     return this.PerformanceComparer.Compare(this.probs.get_Item(e.get_Target()).get_Item(i - 1), this.TestGraph.Cost(e) + this.costs.get_Item(e.get_Target()).get_Item(i - 1), this.probs.get_Item(e.get_Source()).get_Item(i), this.costs.get_Item(e.get_Source()).get_Item(i));
 }
 public override void RemoveEdge(IEdge e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("edge");
     }
     base.RemoveEdge(e);
     EdgeCollection edges = this.VertexInEdges.get_Item(e.get_Target());
     if ((edges == null) || !edges.Contains(e))
     {
         throw new EdgeNotFoundException();
     }
     edges.Remove(e);
 }
 public virtual void AddEdge(IEdge e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("vertex");
     }
     if (e.GetType() != this.EdgeProvider.get_EdgeType())
     {
         throw new ArgumentNullException("vertex type not valid");
     }
     if (!this.VertexOutEdges.ContainsKey(e.get_Source()))
     {
         throw new VertexNotFoundException("Could not find source vertex");
     }
     if (!this.VertexOutEdges.ContainsKey(e.get_Target()))
     {
         throw new VertexNotFoundException("Could not find target vertex");
     }
     if (!this.AllowParallelEdges && this.ContainsEdge(e.get_Source(), e.get_Target()))
     {
         throw new ArgumentException("graph does not allow duplicate edges");
     }
     this.EdgeProvider.UpdateEdge(e);
     this.VertexOutEdges.get_Item(e.get_Source()).Add(e);
 }
 internal bool Relax(IEdge e)
 {
     double d = this.distances.get_Item(e.get_Source());
     double b = this.distances.get_Item(e.get_Target());
     double w = this.weights.get_Item(e);
     if (this.Compare(this.Combine(d, w), b))
     {
         this.distances.set_Item(e.get_Target(), this.Combine(d, w));
         return true;
     }
     return false;
 }
 public void Visit(IEdge se, int depth)
 {
     if (depth <= this.maxDepth)
     {
         if (se == null)
         {
             throw new ArgumentNullException("se");
         }
         this.EdgeColors.set_Item(se, 2);
         this.OnTreeEdge(se);
         IEdgeEnumerator enumerator = this.VisitedGraph.OutEdges(se.get_Target()).GetEnumerator();
         while (enumerator.MoveNext())
         {
             IEdge e = enumerator.get_Current();
             if (this.EdgeColors.get_Item(e) == null)
             {
                 this.OnDiscoverTreeEdge(se, e);
                 this.Visit(e, depth + 1);
             }
             else
             {
                 if (this.EdgeColors.get_Item(e) == 2)
                 {
                     this.OnBackEdge(e);
                     continue;
                 }
                 this.OnForwardOrCrossEdge(e);
             }
         }
         this.EdgeColors.set_Item(se, 1);
         this.OnFinishEdge(se);
     }
 }
 protected IEdge FindReversedEdge(IEdge edge)
 {
     IEdgeEnumerator enumerator = this.VisitedGraph.OutEdges(edge.get_Target()).GetEnumerator();
     while (enumerator.MoveNext())
     {
         IEdge edge2 = enumerator.get_Current();
         if (edge2.get_Target() == edge.get_Source())
         {
             return edge2;
         }
     }
     return null;
 }
 private void PushFlow(IEdge e)
 {
     EdgeDoubleDictionary dictionary;
     IEdge edge;
     EdgeDoubleDictionary dictionary2;
     IEdge edge2;
     VertexDoubleDictionary dictionary3;
     IVertex vertex3;
     VertexDoubleDictionary dictionary4;
     IVertex vertex4;
     IVertex vertex = e.get_Source();
     IVertex vertex2 = e.get_Target();
     double num = Math.Min(this.excessFlow.get_Item(vertex), base.ResidualCapacities.get_Item(e));
     (dictionary = base.ResidualCapacities).set_Item(edge = e, dictionary.get_Item(edge) - num);
     (dictionary2 = base.ResidualCapacities).set_Item(edge2 = base.ReversedEdges.get_Item(e), dictionary2.get_Item(edge2) + num);
     (dictionary3 = this.excessFlow).set_Item(vertex3 = vertex, dictionary3.get_Item(vertex3) - num);
     (dictionary4 = this.excessFlow).set_Item(vertex4 = vertex2, dictionary4.get_Item(vertex4) + num);
 }