示例#1
0
        private void Initialize()
        {
            distanceToSink.Clear();
            flow.Clear();
            excess.Clear();
            activeNodes.Clear();
            sourceGroup.Clear();
            sourceGroup.AddRange(Sources);
            nodesAtDistance[0] = Set <NodeType> .FromEnumerable(Sinks);

            foreach (NodeType sink in Sinks)
            {
                distanceToSink[sink] = 0;
            }
            Set <NodeType> nodesAtDistance1 = new Set <NodeType>();

            foreach (NodeType node in graph.Nodes)
            {
                if (!Sources.Contains(node) && !Sinks.Contains(node))
                {
                    nodesAtDistance1.Add(node);
                }
            }
            nodesAtDistance[1] = nodesAtDistance1;
            foreach (NodeType source in Sources)
            {
                if (!Sinks.Contains(source))
                {
                    distanceToSink[source] = int.MaxValue;
                }
                foreach (EdgeType edge in graph.EdgesOutOf(source))
                {
                    float f = capacity(edge);
                    flow[edge] = f;
                    if (!IsSinkEdge(edge))
                    {
                        NodeType target = graph.TargetOf(edge);
                        if (!Sources.Contains(target) && !Sinks.Contains(target))
                        {
                            excess[target] += f;
                            activeNodes.Add(target);
                        }
                    }
                }
                foreach (EdgeType edge in graph.EdgesInto(source))
                {
                    if (!IsSinkEdge(edge))
                    {
                        float f = reverseCapacity(edge);
                        flow[edge] = -f;
                        NodeType target = graph.SourceOf(edge);
                        if (!Sources.Contains(target) && !Sinks.Contains(target))
                        {
                            excess[target] += f;
                            activeNodes.Add(target);
                        }
                    }
                }
            }
        }
示例#2
0
        public void ProcessEdge(EdgeType edge)
        {
            NodeType source = graph.SourceOf(edge);
            NodeType target = graph.TargetOf(edge);

            if (RootDiscoverTime[target] < RootDiscoverTime[source])
            {
                RootDiscoverTime[source] = RootDiscoverTime[target];
            }
        }
示例#3
0
 public NodeType SourceOf(EdgeType edge)
 {
     return(graph.SourceOf(edge));
 }