When would you use an edge list graph data structure instead of an adjacency list or adjacency matrix?

In what applications would you choose an edge list over an adjacency list or an adjacency matrix?

Sample Question, VisuAlgo: Which best graph DS(es) should you use to store a simple undirected graph with 200 vertices, 19900 edges, and the edges need to be sorted? Suppose your computer only has enough memory to store 40000 entries.

There are three choices: adjacency lists, adjacency matrix, and an edge list.

Edge lists are the correct answer here because sorting by weight is most efficient, but what are some other use cases?

Thanks!

Find the probability of occurrence of each edge in a graph having $n$ nodes after $k$ operations

Given a graph with $ n$ nodes . The adjacency matrix of the graph is given. We do $ k$ operations on this graph. In each operation we choose two distinct nodes $ i$ and $ j$ (there are $ (n*(n-1))/2$ such choices) equiprobably (all choices are equiprobable) and if there exists a edge between $ i$ and $ j$ we delete that edge or else we draw an edge between the chosen pair of nodes.
We have to output a $ n*n$ matrix where the element at $ (i,j)th$ position denotes the probability of occurrence of edge connecting the nodes $ i$ and $ j$ in the final resulting graph.
The constraints on n and k are $ n<=50$ and $ k<=50$ .
I tried it using dynamic programming but could figure out transitions properly.
Can you please help me out.

What is considered an asymptotic improvement for graph algorithms?

Lets say we are trying to solve some algorithmic problem A that is dependent on input of size n. we say algorithm B that runs in time T(n), is asymptotically better than algorithm C which runs in time G(n) if we have: G(n) = O(T(n)), but T(n) is not O(G(n)).

My question is related to the asymptotic running time of graph algorithms, which is usually dependent on |V| and |E|. Specifically I want to focus on Prim’s algorithm. If we implement the priority queue with a binary heap the run-time would be O(ElogV). With Fibonacci heap we could get a run-time of O(VlogV + E).

My question is do we say that O(VlogV + E) is asymptotically better than O(ElogV)?

Let me clarify: I know that if the graph is dense the answer is yes. But if E=O(V) both of the solutions are the same. I am more interested in what is usually defined as an asymptotic improvement in the case we have more than one variable, and even worse – the variables are not independent (V-1<=E<V^2, since we assume the graph is connected for Prim’s algorithm).

Thanks!

How can follow this this guide to construct a graph with matrix/reachability

Let’s we have k matrices. For example we have 3 now, where first one is 8×5 ($ a_1$ x $ b_1$ ), second one is 5 x 6 ($ a_2$ x $ b_2$ ) and last one is 6 x 8 ($ a_3$ x $ b_3$ ). And our goal is to figure out if possible to multiply within any given matrices and reach a matrix of dimension x and y, when x and y is given ahead of time. In this example, (8×5) x (5×6) x (6×8), end up a 8×8 matrix. The hints is given, but I cannot visualize. Any more help is appreciated. can understand the first step, but have not idea about the second one.

First, we can define nodes in the graph as the values of each $ a_i$ and each $ b_i$ , and put an edge from $ a_i$ to $ b_i$ .

Second, Whenever there is a chain of matrices $ M_{i1},…M_{ik}$ , we can multiply, then x=$ a_{i1}$ has an edge to $ b_{i1} =a_{i2}$ , and $ a_{i2}$ has an edge to $ b_{i2}$ =$ a_{i3}$ , and so on, up until $ b_{ik}$ =y. So there could be a path from x to y in this graph.

Third, Inversely, for any path from x to y, the edges form a chain of matrices that we can multiply, which create a x x y matrix. therefore, x is reachable from y in the graph iff there is a chain of matrices which from the x x y matrix.

The first step create something like this ?

>  x-->  > n8-->n5 > n5-->n6  > n6-->n8 >   -->y 

What is $ M_{i1}$ , $ a_{i1}$ and $ b_{i1}$ ? How does that differ to $ a_{1}$ ?

Graph of Laplace equation

I have solved the following Laplace equation

a0 = (1/Pi) Integrate[Cos[φ]^2 + Sin[φ]^3, {φ, 0, 2 Pi}] an = (1/Pi) Integrate[(Cos[φ]^2 + Sin[φ]^3)*Cos[n*φ], {φ, 0, 2 Pi}] Plot[an, {n, 0, 10}] bn = (1/Pi) Integrate[(Cos[φ]^2 + Sin[φ]^3)*Sin[n*φ], {φ, 0, 2 Pi}] ann = an*Cos[n*φ] bnn = bn*Sin[n*φ] a = Sum[((r/4)^n)*(ann + bnn), {n, 1, Infinity}] f[r_, φ_] := a0/2 + a ParametricPlot3D[{r,φ, f[r, φ]}, {r, 0, 1}, {φ, 0, 2 Pi}] Plot3D[f[r, φ], {r, 0, 1}, {φ, 0, 2 Pi}] 

My problem is that Plot3D and ParametricPlot3D doesn’t work. Any help?

Fastest Algorithm for finding All Pairs Shortest Paths on Sparse Non-Negative Graph

As discussed here Johnson’s Algorithm can be used to solve the APSP-Problem in $ O(V^2\log V + VE)$ in stead of $ O(V^3)$ for Floyd-Warshall. However, Johnsons Algorithm does quite a bit of work for the case that some weights are negative. Is there a faster way to compute this given that all weights are positive?

Finding paths of length $n$ on a directed graph

Suppose I have the following directed graph

g = Graph[{DirectedEdge[v1, v1, a], DirectedEdge[v1, v1, OverBar[a]],     DirectedEdge[v1, v2, b], DirectedEdge[v2, v2, c],     DirectedEdge[v1, v3, OverBar[b]],     DirectedEdge[v3, v3, OverBar[c]]}, VertexLabels -> "Name",    EdgeLabels -> "Index"] 

First of all, I would prefer to label the edges with the tag of the directed edge, but I’m not sure how to do this.

The main question is, can Mathematica give me all possible paths of length $ n$ on this graph starting from, say, $ v1$ ?