Which path type allows repeated vertices and edges when traversing data in NebulaGraph? - nebula-graph

Which path type allows repeated vertices and edges when traversing data in NebulaGraph?

https://docs.nebula-graph.io/3.3.0/1.introduction/2.1.path/#walk
The answer is the walk. A walk is a finite or infinite sequence of edges. Both vertices and edges can be repeatedly visited in graph traversal.

Related

First time visited nodes form a spanning tree that has a same number of edges in both BFS and DFS

I am trying to state, whether the statement is true:
During a DFS/BFS, first time visited nodes form a spanning tree, that has the same number of edges whether you use DFS or BFS.
Is it true? Thanks!
Yes, DFS and BFS generate trees with the same number of edges. DFS and BFS create trees with different shapes. But in both cases, each vertex is connected by an edge with its neighboring vertex. There is no circle in the tree. Then the number of edges should be the same for DFS and BFS.

Adjacency list indegree

I was solving this CLRS problem, which asked to find out the indegree of every vertex of a graph G(V,E). I found out the solution to be O(|E|) as we only have to scan through all the edges to find out the degrees of all vertices.
But most of the solutions, I found online, say that it is O(|V|+|E|). How come? How are the vertices accounting for the time taken?
If we suppose that the implementation of the digraph uses objects for vertices and each vertex has an associated list of successors and no additional data structures, then it will be impossible to iterate the edges directly.
If the digraph is connected, then each vertext has at least one associated edge. This means that iteration over the edges via iteration over the vertices takes O(|E|) time - the iteration over the vertices does not increase the running time, which is dominated by the number of edges.
If the digraph is not connected, then the iteration over the vertices is not necessarily dominated by the number of edges; even isolated vertices have to be processed just to find out that they have no associated outgoing arcs, which can be done in O(|V|+|E|) time.
In total, the runtime bound of O(|V|+|E|) is correct in either case; however, for a connected digraph (or an implementation which permits direct iteration over the edges regardless of the number of vertices) one can obtain a tighter runtime bound of O(|E|).

Finding all maximal transitive closured subgraphs in given graph

I'm trying to solve the following problem:
I have an directed graph G = (E,V) which has a low number of edges. Now I try to find all subgraphs in it which are transitive closured and maximal which means there should be no subgraph which ist part of another subgraph.
The first idea I had was to start at every Node doing a DFS and on every step look if all edges for the closure exists but the performance is horrible. So I wonder if there is any faster algorithm

What is the most amount of edges a directed graph can have without having a cycle?

Working on a graph, and this information would be useful, but it is hard to calculate. Thanks!
Attempted solution: Run a BFS and for each subsequent layer add an edge from all vertices of one BFS layer to all vertices of the next BFS layer.
Your attempt would give the maximum number of edges. Another way to look at it is to number the vertices 1 through n, and have an edge connecting each vertex to all higher numbered vertices, for a total of n(n-1)/2 edges.
To see that you can’t have any more edges, you just have to realize that once you have more than n(n-1)/2 edges, there must be some pair of vertices connected to each other in each direction, forming a cycle.

Determine if undirected graph is connected

I came across this posting from a while back:
Best algorithm to determine if an undirected graph is a tree
It says that to determine if an undirected graph is a tree, you just have to check if it has a cycle. However, don't you have to make sure the graph is connected? I was taught that a tree is connected and acyclic. How is checking only for acyclicity sufficient?
Thanks.
You're right. If the graph is acyclic, then it's a forest. In addition, if it only has one component, then it's a tree.
What the algorithm mentioned does is look for back edges. If it finds one, then the graph is not a tree. If it doesn't find one and the algorithm visited n-1 edges before running out of edges, then it IS a tree, because having visited n-1 edges means that the graph is indeed connected (a tree with n vertices has n-1 edges). If the algorithm ran out of edges but didn't reach n-1 visited edges, then it means the graph is not connected, hence it is not a tree.

Resources