public PredecessorRecorderVisitor(VertexEdgeDictionary predecessors)
 {
     if (predecessors == null)
     {
         throw new ArgumentNullException("predecessors");
     }
     this.predecessors = predecessors;
     this.endPathVertices = new VertexCollection();
 }
 public OptimalStrategy(VertexEdgeDictionary successors)
 {
     this.successors = new VertexEdgeDictionary();
     if (successors == null)
     {
         throw new ArgumentNullException("successors");
     }
     this.successors = successors;
 }
Example #3
0
        public VertexEdgeDictionary <TVertex, TEdge> Clone()
        {
            var clone = new VertexEdgeDictionary <TVertex, TEdge>(this.Count);

            foreach (var kv in this)
            {
                clone.Add(kv.Key, kv.Value.Clone());
            }
            return(clone);
        }
        public EdmundsKarpMaximumFlow(
            Graph g,
            EdgeDoubleDictionary edgeCapacities
            )
            : base(g)
        {
            if (edgeCapacities == null)
                throw new ArgumentNullException("Edge capacities");

            m_EdgeCapacities = edgeCapacities;
            m_ResidualEdgeCapacities = null;
            m_Predecessors = new VertexEdgeDictionary();
        }
 public CyclePoppingRandomTreeAlgorithm(IVertexListGraph g)
 {
     this.visitedGraph = null;
     this.colors = new VertexColorDictionary();
     this.edgeChain = new NormalizedMarkovEdgeChain();
     this.successors = new VertexEdgeDictionary();
     this.rnd = new Random((int) DateTime.Now.Ticks);
     if (g == null)
     {
         throw new ArgumentNullException("g");
     }
     this.visitedGraph = g;
 }
Example #6
0
		/// <summary>Constructs a maximum flow algorithm.</summary>
		/// <param name="g">Graph to compute maximum flow on.</param>
		/// <param name="capacities">edge capacities</param>
		/// <param name="reversedEdges">reversed edge map</param>
		/// <exception cref="ArgumentNullException"><paramref name="g"/> or
		/// <paramref name="capacities"/> or <paramref name="reversedEdges"/> is a null
		/// reference.
		/// </exception>
		public MaximumFlowAlgorithm(
			IVertexListGraph g,
			EdgeDoubleDictionary capacities,
			EdgeEdgeDictionary reversedEdges
			)
		{
			if (g==null)
				throw new ArgumentNullException("g");
			if (capacities==null)
				throw new ArgumentNullException("capacities");
			if (reversedEdges==null)
				throw new ArgumentNullException("reversedEdges");
		
			this.visitedGraph=g;
			this.capacities=capacities;
			this.reversedEdges=reversedEdges;
		
			this.predecessors=new VertexEdgeDictionary();
			this.residualCapacities=new EdgeDoubleDictionary();
			this.colors = new VertexColorDictionary();
        }
        internal void Augment(Vertex src, Vertex sink, VertexEdgeDictionary predecessors)
        {
            // find minimum residual capacity along the augmenting path
            double delta = double.MaxValue;
            Edge e = predecessors[sink];
            Vertex u = null;
            do
            {
                delta = Math.Min(delta, ResidualEdgeCapacities[e]);
                u = e.Source;
                e = predecessors[u];
             } while (u != src);

            // push delta units of flow along the augmenting path
            e = predecessors[sink];
            do
            {
                ResidualEdgeCapacities[e] -= delta;
                ResidualEdgeCapacities[ReverseEdges[e]] += delta;
                u = e.Source;
                e = predecessors[u];
            } while (u != src);
        }
        public void GenerateWalls(int outi, int outj, int ini, int inj)
        {
            // here we use a uniform probability distribution among the out-edges
            CyclePoppingRandomTreeAlgorithm pop =
                new CyclePoppingRandomTreeAlgorithm(this.graph);

            // we can also weight the out-edges
            /*
            EdgeDoubleDictionary weights = new EdgeDoubleDictionary();
            foreach(IEdge e in this.graph.Edges)
                weights[e]=1;
            pop.EdgeChain = new WeightedMarkovEdgeChain(weights);
            */
            IVertex root = this.latice[outi,outj];
            if (root==null)
                throw new ArgumentException("outi,outj vertex not found");

            pop.RandomTreeWithRoot(this.latice[outi,outj]);
            this.successors = pop.Successors;

            // build the path to ini, inj
            IVertex v = this.latice[ini,inj];
            if (v==null)
                throw new ArgumentException("ini,inj vertex not found");
            this.outPath = new EdgeCollection();
            while (v!=root)
            {
                IEdge e = this.successors[v];
                if (e==null)
                    throw new Exception();
                this.outPath.Add(e);
                v = e.Target;
            }
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 public PredecessorRecorderVisitor()
 {
     this.predecessors = new VertexEdgeDictionary();
     this.endPathVertices = new VertexCollection();
 }
 /// <summary>
 /// Constructor, uses the given predecessor map.
 /// </summary>
 /// <param name="predecessors">Predecessor map</param>
 /// <exception cref="ArgumentNullException">predecessors is null</exception>
 public PredecessorRecorderVisitor(VertexEdgeDictionary predecessors)
 {
     if (predecessors == null)
         throw new ArgumentNullException("predecessors");
     m_Predecessors = predecessors;
 }
 /// <summary>
 /// Default constructor
 /// </summary>
 public PredecessorRecorderVisitor()
 {
     m_Predecessors = new VertexEdgeDictionary();
 }
 public OptimalStrategy()
 {
     this.successors = new VertexEdgeDictionary();
 }