public static void Init(this IPathView pathView) { pathView.Update(); for (var i = 0; i < pathView.Graph.NodeCount; i++) { if (pathView.MustBeRelevant[i]) { pathView.SelectPath(i); } } }
public void Check(TilePropagator propagator) { pathView.Update(); var info = PathConstraintUtils.GetArticulationPoints(pathView.Graph, pathView.CouldBePath, pathView.MustBeRelevant); var isArticulation = info.IsArticulation; for (var i = 0; i < pathView.Graph.NodeCount; i++) { if (isArticulation[i]) { propagator.SetContradiction("Loop constraint found articulation point.", this); return; } } }
public void Check(TilePropagator propagator) { pathView.Update(); var graph = pathView.Graph; var mustBePath = pathView.MustBePath; // TODO: Support relevant? var visited = new bool[graph.NodeCount]; for (var i = 0; i < graph.NodeCount; i++) { if (!mustBePath[i]) { continue; } if (visited[i]) { continue; } // Start DFS var stack = new Stack <(int, int)>(); stack.Push((-1, i)); while (stack.Count > 0) { var(prev, u) = stack.Pop(); if (visited[u]) { propagator.SetContradiction(); return; } visited[u] = true; foreach (var v in graph.Neighbours[u]) { if (!mustBePath[v]) { continue; } if (v == prev) { continue; } stack.Push((u, v)); } } } }