## How do I check if a directed graph is acyclic?

How do I check if a directed graph is acyclic? And how is the algorithm called? I would appreciate a reference. Answer I would try to sort the graph topologically, and if you can’t, then it has cycles. AttributionSource : Link , Question Author : nes1983 , Answer Author : Community

## how to draw directed graphs using networkx in python?

I have some nodes coming from a script that I want to map on to a graph. In the below, I want to use Arrow to go from A to D and probably have the edge colored too in (red or something). This is basically, like a path from A to D when all other … Read more

## GraphViz – How to connect subgraphs?

In the DOT language for GraphViz, I’m trying to represent a dependency diagram. I need to be able to have nodes inside a container and to be able to make nodes and/or containers dependent on other nodes and/or containers. I’m using subgraph to represent my containers. Node linking works just fine, but I can’t figure … Read more

## Best algorithm for detecting cycles in a directed graph [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago. This post was edited and submitted for review last month and failed to reopen the post: Original close reason(s) … Read more

## Intuition behind Floyd-Warshall being faster

I know the Floyd-Warshall, and I also clearly understand the proof of running time of $O(V^3)$ of F-W algorithm. However, consider this algorithm: Let $dp[i][j][n]$ denote the shortest path from $V_i$ to $V_j$ using at most $n$ vertices. Use $dp[i][j][n] = \min_{V_k\text{ adjacent to } V_i} (e_{ik}+dp[k][j][n-1], dp[i][j][n-1])$ to compute all values of $dp[i][j][n]$. This … Read more

## What happens if I replace << with ≤\le in Dijkstra's algorithm?

The following is Dijkstra’s algorithm for finding the shortest path in a graph. I know something wrong happens if I replace d[u] + weight(u,v) < d[v] with d[u] + weight(u,v) <= d[v]. What would be an example of the algorithm working incorrectly with that replacement? def dijkstraShortestPath(G,s,t): d[v] = Infinity for all v in G.vertices … Read more

## Finding shortest cycle in graph with positive weights

Given a graph G, with all positive weights, find the shortest cycle length in O(V^3) My idea is, negate al the edges, apply floyd-warshall algorithm and then for all i, find the largest M[i][i] where M is the final distance matrix, and then negate M[i][i] and return. Could this work? I know floyd can be … Read more

## Enumerate all re-convergent paths in a digraph (with cycles)

I’m looking for an algorithm to count and enumerate (separately, if differing complexity) all the reconvergent pathsets in a simple, directed, non-weighted graph, which may contain cycles. That is, for every vertex vi of in-degree >1, determine if any pair of its direct ancestors have a lowest common ancestor ui and, if so, count it … Read more

## Decremental connectivity on general graphs

I’m looking for an efficient solution to the problem of tracking the number of connected components in a general graph under edge deletions. General connectivity algorithms like that from Holm, Lichtenberg and Thorup solve this problem and also feature edge insertion and connectivity queries, which I dont really need, but have an amortized poly-logarithmic update … Read more

## Find the minimum edge size, L, that would allow the construction of a tree whose edges connect all given 2-d points, but no edge exceeds length L

Given a set of points in the 2-d plane, find the minimum edge size, L, that would allow the construction of a tree whose edges connect all given points, but no edge exceeds length L. Here is an algorithm, which I think might work but seems slow: Pick a random point find the distance of … Read more