public void ReducePathDistance(IVertexDistanceMatrix distances, IVertex source, IVertex target, IVertex intermediate) { if (distances.Distance(source, target) == 0.0) { distances.SetDistance(source, target, Convert.ToDouble((distances.Distance(source, intermediate) != 0.0) && (distances.Distance(intermediate, target) != 0.0))); } }
public void ReducePathDistance( IVertexDistanceMatrix distances, IVertex source, IVertex target, IVertex intermediate ) { distances.SetDistance(source,target, distances.Distance(source,intermediate) + distances.Distance(intermediate,target) ); }
public void ReducePathDistance( IVertexDistanceMatrix distances, IVertex source, IVertex target, IVertex intermediate ) { distances.SetDistance(source, target, distances.Distance(source, intermediate) + distances.Distance(intermediate, target) ); }
public bool TestDistance( IVertexDistanceMatrix distances, IVertex source, IVertex target, IVertex intermediate ) { return (distances.Distance(source, intermediate) + distances.Distance(intermediate, target) < distances.Distance(source, target)); }
public void ReducePathDistance(IVertexDistanceMatrix distances, IVertex source, IVertex target, IVertex intermediate) { if ((source == target) && (distances.Distance(source, target) < 0.0)) { throw new Exception("Negative cycle"); } }
public void ReducePathDistance( IVertexDistanceMatrix distances, IVertex source, IVertex target, IVertex intermediate ) { if (distances.Distance(source, target) == 0) { distances.SetDistance(source, target, Convert.ToDouble( (distances.Distance(source, intermediate) != 0) && (distances.Distance(intermediate, target) != 0) ) ); } }
public void ReducePathDistance( IVertexDistanceMatrix distances, IVertex source, IVertex target, IVertex intermediate ) { if (source == target && distances.Distance(source, target) < 0) { throw new Exception(@"Negative cycle"); } }
/// <summary> /// Checks the graph for connectivity and negative cycles /// </summary> /// <param name="costs">cost distionary</param> /// <exception cref="NegativeCycleException">graph has negatice cycle.</exception> /// <exception cref="GraphNotStronglyConnectedException">graph is not strongly connected</exception> public void CheckConnectivityAndNegativeCycles(IVertexDistanceMatrix costs) { foreach (IVertex u in VisitedGraph.Vertices) { if (costs != null && costs.Distance(u, u) < 0) { throw new NegativeCycleException("Graph has negative cycle"); } foreach (IVertex v in VisitedGraph.Vertices) { if (!DefinedPaths.Contains(new VertexPair(u, v))) { throw new Exception("Graph is not strongly connected"); } } } }
public void CheckConnectivityAndNegativeCycles(IVertexDistanceMatrix costs) { IVertexEnumerator enumerator = this.VisitedGraph.get_Vertices().GetEnumerator(); while (enumerator.MoveNext()) { IVertex vertex = enumerator.get_Current(); if ((costs != null) && (costs.Distance(vertex, vertex) < 0.0)) { throw new NegativeCycleException("Graph has negative cycle"); } IVertexEnumerator enumerator2 = this.VisitedGraph.get_Vertices().GetEnumerator(); while (enumerator2.MoveNext()) { IVertex vertex2 = enumerator2.get_Current(); if (!this.DefinedPaths.Contains(new VertexPair(vertex, vertex2))) { throw new Exception("Graph is not strongly connected"); } } } }
/// <summary> /// Checks the graph for connectivity and negative cycles /// </summary> /// <param name="costs">cost distionary</param> /// <exception cref="NegativeCycleException">graph has negatice cycle.</exception> /// <exception cref="GraphNotStronglyConnectedException">graph is not strongly connected</exception> public void CheckConnectivityAndNegativeCycles(IVertexDistanceMatrix costs) { foreach(IVertex u in VisitedGraph.Vertices) { if( costs!=null && costs.Distance(u,u) < 0 ) throw new NegativeCycleException("Graph has negative cycle"); foreach(IVertex v in VisitedGraph.Vertices) if(!DefinedPaths.Contains(new VertexPair(u,v))) throw new Exception("Graph is not strongly connected"); } }
public bool TestDistance(IVertexDistanceMatrix distances, IVertex source, IVertex target, IVertex intermediate) { return ((distances.Distance(source, intermediate) + distances.Distance(intermediate, target)) < distances.Distance(source, target)); }