コード例 #1
0
ファイル: MinCut.cs プロジェクト: ScriptBox21/dotnet-infer
        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 Clear()
 {
     queue.Clear();
     bfs.Clear();
     visitCount = 0;
     IsScheduled.Clear();
     MaxScheduledCost = default(Cost);
 }
コード例 #3
0
        public IndexedProperty <int, T> CreateNodeData <T>(T defaultValue)
        {
            T[] data = new T[info.Length];
            IndexedProperty <int, T> prop = MakeIndexedProperty.FromArray <T>(data, defaultValue);

            prop.Clear();
            return(prop);
        }
コード例 #4
0
 public IndexedProperty <int, T> CreateEdgeData <T>(T defaultValue = default(T))
 {
     if (IsReadOnly)
     {
         T[] data = new T[edges.Count];
         IndexedProperty <int, T> prop = MakeIndexedProperty.FromArray <T>(data, defaultValue);
         prop.Clear();
         return(prop);
     }
     else
     {
         return(new IndexedProperty <int, T>(new Dictionary <int, T>(), defaultValue));
     }
 }
コード例 #5
0
 public IndexedProperty <int, T> CreateNodeData <T>(T defaultValue = default(T))
 {
     if (NodeCountIsConstant)
     {
         T[] data = new T[inEdges.Count];
         IndexedProperty <int, T> prop = MakeIndexedProperty.FromArray <T>(data, defaultValue);
         prop.Clear();
         return(prop);
     }
     else
     {
         return(new IndexedProperty <int, T>(new Dictionary <int, T>(), defaultValue));
     }
 }
コード例 #6
0
 public virtual void Clear()
 {
     IsVisited.Clear();
 }
コード例 #7
0
 public void Clear()
 {
     isBlocked.Clear();
     blockedSources.Clear();
     onPath.Clear();
 }