Exemple #1
0
        public Pebbler(Hypergraph.Hypergraph <GeometryTutorLib.ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> graph,
                       PebblerHypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> pGraph)
        {
            this.graph        = graph;
            this.pebblerGraph = pGraph;

            forwardPebbledEdges  = new HyperEdgeMultiMap <Hypergraph.EdgeAnnotation>(pGraph.vertices.Length);
            backwardPebbledEdges = new HyperEdgeMultiMap <Hypergraph.EdgeAnnotation>(pGraph.vertices.Length);

            forwardPebbledEdges.SetOriginalHypergraph(graph);
            backwardPebbledEdges.SetOriginalHypergraph(graph);
        }
Exemple #2
0
        //
        // Given a node, pebble the reachable parts of the graph (in the forward direction)
        // We pebble in a breadth first manner
        //
        private void ForwardTraversal(HyperEdgeMultiMap <Hypergraph.EdgeAnnotation> edgeDatabase, List <int> nodesToPebble)
        {
            List <int> worklist = new List <int>(nodesToPebble);

            //
            // Pebble until the list is empty
            //
            while (worklist.Any())
            {
                // Acquire the next value to consider
                int currentNodeIndex = worklist[0];
                worklist.RemoveAt(0);

                // Pebble the current node as a forward node and percolate forward
                pebblerGraph.vertices[currentNodeIndex].pebbled = true;

                // For all hyperedges leaving this node, mark a pebble along the arc
                foreach (PebblerHyperEdge <Hypergraph.EdgeAnnotation> currentEdge in pebblerGraph.vertices[currentNodeIndex].edges)
                {
                    if (!Utilities.RESTRICTING_AXS_DEFINITIONS_THEOREMS || (Utilities.RESTRICTING_AXS_DEFINITIONS_THEOREMS && currentEdge.annotation.IsActive()))
                    {
                        if (!currentEdge.IsFullyPebbled())
                        {
                            // Indicate the node has been pebbled by adding to the list of pebbled vertices; should not have to be a unique addition
                            Utilities.AddUnique <int>(currentEdge.sourcePebbles, currentNodeIndex);

                            // With this new node, check if the edge is full pebbled; if so, percolate
                            if (currentEdge.IsFullyPebbled())
                            {
                                // Has the target of this edge been pebbled previously? Pebbled -> Pebbled means we have a backward edge
                                if (!IsNodePebbled(currentEdge.targetNode))
                                {
                                    // Success, we have an edge
                                    // Construct a static set of pebbled hyperedges for problem construction
                                    edgeDatabase.Put(currentEdge);

                                    // Add this node to the worklist to percolate further
                                    if (!worklist.Contains(currentEdge.targetNode))
                                    {
                                        worklist.Add(currentEdge.targetNode);
                                        worklist.Sort();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }