Recursively calculates the potentials of the graph, from the
starting point you specify with ->setStartingVertex(), traversing
the graph due to Vertex's $connections attribute.

@param VertexInterface $vertex
353748
protected function calculatePotentials(VertexInterface $vertex)
    {
        $connections = $vertex->getConnections();
        $sorted = array_flip($connections);

        krsort($sorted);

        foreach ($connections as $id => $distance) {
            $v = $this->getGraph()->getVertex($id);
            $v->setPotential($vertex->getPotential() + $distance, $vertex);

            foreach ($this->getPaths() as $path) {
                $count = count($path);

                if ($path[$count - 1]->getId() === $vertex->getId()) {
                    $this->paths[] = array_merge($path, array($v));
                }
            }
        }

        $vertex->markPassed();

        // Get loop through the current node's nearest connections
        // to calculate their potentials.
        foreach ($sorted as $id) {
            $vertex = $this->getGraph()->getVertex($id);

            if (!$vertex->isPassed()) {
                $this->calculatePotentials($vertex);
            }
        }
    }
502901
private function visit(Vertex $definition)
    {
        $definition->state = Vertex::IN_PROGRESS;

        foreach ($definition->dependencyList as $dependency) {
            if ( ! isset($this->nodeList[$dependency])) {
                throw new \RuntimeException(sprintf(
                    'Fixture "%s" has a dependency of fixture "%s", but it not listed to be loaded.',
                    get_class($definition->value),
                    $dependency
                ));
            }

            $childDefinition = $this->nodeList[$dependency];

            // allow self referencing classes
            if ($definition === $childDefinition) {
                continue;
            }

            switch ($childDefinition->state) {
                case Vertex::VISITED:
                    break;
                case Vertex::IN_PROGRESS:
                    if ( ! $this->allowCyclicDependencies) {
                        throw new CircularReferenceException(
                            sprintf(
                                'Graph contains cyclic dependency between the classes "%s" and'
                                .' "%s". An example of this problem would be the following: '
                                .'Class C has class B as its dependency. Then, class B has class A has its dependency. '
                                .'Finally, class A has class C as its dependency.',
                                $definition->value->getName(),
                                $childDefinition->value->getName()
                            )
                        );
                    }
                    break;
                case Vertex::NOT_VISITED:
                    $this->visit($childDefinition);
            }
        }

        $definition->state = Vertex::VISITED;

        $this->sortedNodeList[] = $definition->value;
    }
1071372
def add_vertex(vertex, name: nil)
      name ||= callback(vertex, :name)
      insert_vertex(vertex, name)
      define_currified_methods(vertex, :vertex) if @currify
      callback(vertex, :added_to_graph, self)
      self
    end
353920
public function boot($graph): NetworkInterface
    {
        switch (true) {
            case (is_a($graph, Graph::class)):
                break;
            case (is_file($graph)):
                $graph = Graph::loadFile($graph);
                break;
            case is_string($graph) && is_file($graph):
                $graph = Graph::loadFile($graph);
                break;
            case (is_string($graph)):
                $graph = Graph::loadString($graph);
                break;
            default:
                throw new InvalidTypeException(
                    "Graph has to be either a Graph object or a compatible definition file/string"
                );
        }

        $graph->on(self::EVENT_ADD, [$this, 'addNode']);
        $graph->on(self::EVENT_REMOVE, [$this, 'removeNode']);
        $graph->on(self::EVENT_ADD_EDGE, [$this, 'addEdge']);
        $graph->on(self::EVENT_REMOVE_EDGE, [$this, 'removeEdge']);

        /** @todo think of caching graphs here, maybe */
        $this->graph = $graph;
        $this->loadGraph($graph);

        return $this;
    }
170298
public function afterNodeCreate(NodeInterface $node)
    {
        if (!$this->eventEmittingService->isEnabled()) {
            return;
        }

        /* @var $nodeEvent NodeEvent */
        $nodeEvent = array_pop($this->currentNodeAddEvents);
        $nodeEvent->setNode($node);
        $this->eventEmittingService->popContext();
        $this->eventEmittingService->add($nodeEvent);
    }
1361161
protected function init(JobInterface $job, JobGraph $graph, Io\IoDescriptor $io = null)
    {
        $contexts = [];
        $inputs = $this->buildInputs($io);

        foreach ($inputs as $input) {
            $contexts[] = $this->ctxFactory->create($job, $input, $graph->current());
        }

        $msgs = $this->msgFactory->createInitMsgs($contexts);
        foreach ($msgs as $msg) {
            $this->push($msg);
        }
    }
1081253
void connectTo(final Node<T> o) {
    if (!this.graph.equals(o.graph))
      throw new IllegalArgumentException("Cannot connect to nodes of two different graphs.");
    if (this.equals(o)) {
      return;
    }
    neighbours.add(o);
  }
199237
def find_connection(v1, v2)
      raise "not a vertex" unless v1.is_a?(Vertex) && v2.is_a?(Vertex)
      raise "Vertices not connected" if !is_connected?(v1, v2)
      connection = v1.edges.select {|edge| edge.connection.include?(v2)}
      raise "Error finding connection" if connection.length > 1
      connection.first
    end
877378
private void init() {

        /********************************************************************/
        /*
         * vertex: stored all the vertices for the Graph G vertex[G] nodes of
         * vector compGraphNodes are stored in vertex
         */
        List<Integer> vertex = new ArrayList<Integer>(); //Initialization of ArrayList vertex

        int vertexCount = compGraphNodes.size() / 3;

        //System.out.println("ArrayList vertex is initialized");
        for (int a = 0; a < vertexCount; a++) {
            vertex.add(compGraphNodes.get(a * 3 + 2));
            //System.out.print("vertex[" + index + "]: " + compGraphNodes.get(index * 3 + 2) + " ");
        }
        //System.out.println();

        vertex.add(0);
        // System.out.println("ArrayList vertex :" + vertex);

        /*
         * processedVertex: is index set of vertices which have already been
         * used
         */
        List<Integer> processedVertex = new ArrayList<Integer>();
        /*
         * Let processedVertex be the set of Nodes already been used in the
         * initialization
         */
        initIterator(vertex, processedVertex);
        processedVertex.clear();
        //System.out.println("maxCliquesSet: " + maxCliquesSet);

    }
1128396
protected function moveNodeToDestinationPath(NodeInterface $node, $destinationPath)
    {
        $nodeData = $node->getNodeData();
        $possibleShadowedNodeData = $nodeData->move($destinationPath, $this->context->getWorkspace());
        if ($node instanceof Node) {
            $node->setNodeData($possibleShadowedNodeData);
        }
    }
776954
def _add_edge_to_vertex(self, vertex_id, edge):
        
        connected_to = edge.connected_to(vertex_id)
        if vertex_id not in self.vertices:
            vertex_obj = Vertex(vertex_id)
            self.vertices[vertex_id] = vertex_obj
        self.vertices[vertex_id].edges[connected_to] = edge.weight
1363027
protected function getPathsRecursion(Vertex $start, DirectedEdge $edge)
    {
        // We don't want to visit the same vertex twice within a single path. (avoid loops)
        if (in_array($start->get_data(), $this->current_path)) {
            $this->paths[] = array_reverse($this->current_path);

            return;
        }

        $this->current_path[] = $start->get_data();

        if ($start->incoming_edges->count() == 0) {
            $this->paths[] = array_reverse($this->current_path);

            return;
        }

        /**
         * @var DirectedEdge
         */
        foreach ($start->incoming_edges as $edge) {
            $this->getPathsRecursion($edge->get_source(), $edge);

            //remove the item that was added by the child
            array_pop($this->current_path);
        }
    }
1045145
def add_vertex(self, vertex):
        
        if vertex not in self._vertices:
            self._vertices.add(vertex)
            return True

        return False
1104320
protected function initializeView(ViewInterface $view)
    {
        parent::initializeView($view);

        $this->generateCoreSelectorMenuUsingPageTree();
        /* @var ModuleTemplate $module */ // holds the state of chosen tab
        $module = $this->objectManager->get(ModuleTemplate::class);
        $coreOptimizationTabs = $module->getDynamicTabMenu([], 'coreOptimization');
        $this->view->assign('tabs', $coreOptimizationTabs);
    }
460986
public function copyNode(NodeInterface $node)
    {
        $this->nodeContextPath = $node->getContextPath();
        $this->mode = self::MODE_COPY;
    }
1058517
protected function initializeView(ViewInterface $view): void
    {
        $view->assignMultiple([
            'view' => $this->browserState->get('view'),
            'sortBy' => $this->browserState->get('sortBy'),
            'sortDirection' => $this->browserState->get('sortDirection'),
            'filter' => $this->browserState->get('filter'),
            'activeTag' => $this->browserState->get('activeTag'),
            'activeAssetCollection' => $this->browserState->get('activeAssetCollection'),
            'assetSources' => $this->assetSources,
            'variantsTabFeatureEnabled' => $this->settings['features']['variantsTab']['enable']
        ]);
    }
635137
private function visit($vertex)
    {
        $vertex->state = self::IN_PROGRESS;

        foreach ($vertex->dependencyList as $edge) {
            $adjacentVertex = $this->nodeList[$edge->to];

            switch ($adjacentVertex->state) {
                case self::VISITED:
                    // Do nothing, since node was already visited
                    break;

                case self::IN_PROGRESS:
                    if (isset($adjacentVertex->dependencyList[$vertex->hash]) &&
                        $adjacentVertex->dependencyList[$vertex->hash]->weight < $edge->weight) {
                        // If we have some non-visited dependencies in the in-progress dependency, we
                        // need to visit them before adding the node.
                        foreach ($adjacentVertex->dependencyList as $adjacentEdge) {
                            $adjacentEdgeVertex = $this->nodeList[$adjacentEdge->to];

                            if ($adjacentEdgeVertex->state === self::NOT_VISITED) {
                                $this->visit($adjacentEdgeVertex);
                            }
                        }

                        $adjacentVertex->state = self::VISITED;

                        $this->sortedNodeList[] = $adjacentVertex->value;
                    }
                    break;

                case self::NOT_VISITED:
                    $this->visit($adjacentVertex);
            }
        }

        if ($vertex->state !== self::VISITED) {
            $vertex->state = self::VISITED;

            $this->sortedNodeList[] = $vertex->value;
        }
    }