Find all connected graphs in the set of all graphs.

@return ArrayObject
979957
public function findRootNodes()
    {
        $possibleRoots = new SplObjectStorage();
        foreach ($this->nodes as $node) {
            $possibleRoots[$node] = true;
        }

        // Detect all nodes which couldn't be root
        foreach ($this->dependencies as $node) {
            $nodeDependencies = $this->dependencies[$node];
            foreach ($nodeDependencies as $dependency) {
                $possibleRoots[$dependency] = false;
            }
        }

        // Create array which contains all roots
        $rootNodes = array();
        foreach ($possibleRoots as $node) {
            if ($possibleRoots[$node]) {
                $rootNodes[] = $node;
            }
        }

        return $rootNodes;
    }
487092
public function mapRelatives()
    {
        $relations = collect($this->relations());

        if ($relations->isEmpty()) {
            return false;
        }

        return $this->items = collect($this->all())
            ->map(function ($value, $key) use ($relations) {
                if ($relations->has($key)) {
                    $className = $relations->get($key);

                    return new $className($value);
                }

                return $value;
            })
            ->all();
    }
1172444
private function getRelations()
	{
        if (is_null($this->relations)) {
            $builder = new RelationBuilder();
            $this->relations = $builder->build($this->data);
        }

        return $this->relations;
    }
872520
public function getConnectorsAsArray()
    {
        // Iterate over the connectors nodes and sort them into an array
        $connectors = array();
        /** @var \AppserverIo\Appserver\Core\Api\Node\ConnectorNode $connectorNode */
        foreach ($this->getConnectors() as $connectorNode) {
            // Restructure to an array
            $connectors[] = array(
                'name' => $connectorNode->getName(),
                'type' => $connectorNode->getType(),
                'params' => $connectorNode->getParamsAsArray()
            );
        }

        // Return what we got
        return $connectors;
    }
1037874
public function getRelations():array
    {
        $relations = array_unique(array_merge($this->getAvailableIncludes(), $this->relations));

        return array_filter($relations, function($relation) {
            return $relation !== '*';
        });
    }
464397
public function getRelations()
    {
        if ($this->def->getTarget() === null) {
            return [];
        }

        $relations = [];
        foreach ($this->def->getTarget()->getRelations() as $relation) {
            $relations[$relation->getLocalProperty()] = $relation;
        }

        return $relations;
    }
766515
public function getAllConnectedAccounts() {
		$accounts = array();
		foreach ($this->getAllAccountConnections() as $ac) {
			$accounts[] = $ac->getProperty('coid://accountgateways.cloudobjects.io/connectsTo');
		}
		return $accounts;
	}
826683
public function getRelations()
    {
        $bag = $this->getParameter('relations');

        if (!($bag instanceof Bag)) {
            $bag = new Bag();
        }

        $this->setParameter('relations', $bag);

        return $bag;
    }
1287615
public function getAllParents()
    {
        $closestParents = $this->getParents();

        $allParents = [];

        foreach ($closestParents as $parent) {
            $allParents = array_merge(
                $allParents,
                $parent->getAllParents()
            );
        }

        $allParents = array_unique(
            array_merge(
                $allParents,
                $closestParents->toArray()
            )
        );

        return $allParents;
    }
493334
public function getOrderedProcesses()
    {
        $graph = new DependencyGraph();
        $root = new DependencyGraphNode(self::ROOT_NODE_NAME);
        $graph->addRoot($root);

        $processes = $this->getProcesses();
        $nodes = [];
        foreach ($processes as $process) {
            $processName = $this->getProcessName($process);
            $node = new DependencyGraphNode($processName);
            $graph->addDependency($root, $node);
            $nodes[$processName] = [$process, $node];
        }

        foreach ($nodes as $processName => $nodeDescription) {
            list($process, $node) = $nodeDescription;
            if (!$process instanceof DependentChainProcessInterface) {
                $graph->addDependency($root, $node);
                continue;
            }

            foreach ($process->dependsOn() as $dependencyName) {
                if (!array_key_exists($dependencyName, $nodes)) {
                    throw new UnresolvedDependencyException(sprintf(
                        'Process "%s" is dependent of "%s" which is not found',
                        $processName,
                        $dependencyName
                    ));
                }

                if ($graph->addDependency($node, $nodes[$dependencyName][1]) instanceof Left) {
                    throw new CircularDependencyException(sprintf(
                        'Circular dependency found: %s already depends on %s',
                        $dependencyName, $processName
                    ));
                }
            }
        }

        return array_map(function ($nodeName) use ($nodes) {
            return $nodes[$nodeName][0];
        }, array_filter($graph->flatten(), function ($nodeName) {
            return $nodeName !== self::ROOT_NODE_NAME;
        }));
    }
720939
public function findAll()
    {
        $appNodes = array();
        foreach ($this->getSystemConfiguration()->getApps() as $appNode) {
            $appNodes[$appNode->getPrimaryKey()] = $appNode;
        }
        return $appNodes;
    }
1104538
def connected_edges(G, nodes):
    
    nodes_in_G = collections.deque()
    for node in nodes:
        if not G.has_node(node):
            continue
        nodes_in_G.extend(nx.node_connected_component(G, node))
    edges = G.subgraph(nodes_in_G).edges()
    return edges
110269
public static <T> Set<Set<Node<T>>> compute(final Graph<T> graph) {
    final Set<Set<Node<T>>> connectedComponents = new LinkedHashSet<>();
    final Set<Node<T>> unmarkedNodes = new LinkedHashSet<>(graph.nodes());

    while (!unmarkedNodes.isEmpty()) {
      Set<Node<T>> connectedComp = new LinkedHashSet<>();
      deepFirstSearch(unmarkedNodes.iterator().next(), connectedComp, unmarkedNodes);
      connectedComponents.add(connectedComp);
    }

    return connectedComponents;
  }
523874
public function getQueryParts()
    {
        $this->queryParts = [
            'graphs' => $this->extractGraphs($this->getQuery()),
            'sub_type' => $this->determineSubType($this->getQuery()),
        ];

        $this->unsetEmptyValues($this->queryParts);

        return $this->queryParts;
    }
1142710
def _get_connected_components_adjacency(self, graph, counts):
        ''' '''

        found = set()
        components = list()

        for node in sorted(graph, key=lambda x: counts[x], reverse=True):
            if node not in found:
                # component = self.search(node, graph)
                component = breadth_first_search(node, graph)
                found.update(component)
                components.append(component)
        return components
729357
public function accessibleRelationsToArray()
	{
		$filtered  = [];
		$relations = $this->getArrayableRelations();

		/**
		 * @var $related \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Relations\Pivot
		 */
		foreach ($relations as $key => $related_collection) {
			if (! $this->access_authorizer->canAccess($key)) {
				continue;
			}

			if ($related_collection instanceof Pivot) {
				// Access test done above
				$filtered[$key] = $related_collection;
				continue;
			}

			// Many relation
			if ($related_collection instanceof Collection) {
				foreach ($related_collection as $index => $related) {
					$filtered[$key][$index] = $related->accessibleAttributesToArray();
				}
			} elseif ($related_collection instanceof LaravelModel) {
				// Single relation
				$filtered[$key] = $related_collection->accessibleAttributesToArray();
			}
		}

		return $filtered;
	}
320569
def connected_components(self) -> (dict, dict):
        """"""
        inclusions = utils.completed_graph(self.inclusions)  # allow bottom-up movement
        edges = utils.completed_graph(self.edges) if self.oriented else self.edges
        cc = {}  # maps cc root with nodes in the cc
        subroots = defaultdict(set)  # maps cc root with other roots of the cc
        walked_roots = set()  # all roots that have been walked already
        for root in self.roots:
            if root in walked_roots: continue  # this cc have been done already
            # walk in the graph starting at root
            cc[root] = set([root])
            walked = cc[root]
            stack = list(edges.get(root, ())) + list(inclusions.get(root, ()))
            while len(stack) > 0:
                *stack, curr = stack
                walked.add(curr)
                if curr in self.roots:  # don't do the walk for already found roots
                    walked_roots.add(curr)
                    subroots[root].add(curr)
                for succ in it.chain(edges.get(curr, ()), inclusions.get(curr, ())):
                    if succ not in walked:
                        stack.append(succ)
        return cc, dict(subroots)