Questions tagged [directed-graph]

A directed graph is a set of objects (called vertices or nodes) that are connected together, where all the edges are directed from one vertex to another. A directed graph is sometimes called a digraph or a directed network.

A directed graph (or digraph) is a , or set of nodes connected by edges, where the edges have a direction associated with them

686 questions
23
votes
2 answers

Topological sort of cyclic graph with minimum number of violated edges

I am looking for a way to perform a topological sorting on a given directed unweighted graph, that contains cycles. The result should not only contain the ordering of vertices, but also the set of edges, that are violated by the given ordering. This…
21
votes
4 answers

Creating curved edges with NetworkX in Python3

I would like to use networkx (i would also like to take another framework if you know a better one) to create a graps whose nodes are at fixed positions. At the same time the edges of the graph should not overlap. My previous code looks like…
g3n35i5
  • 485
  • 1
  • 4
  • 14
20
votes
1 answer

Traversal of cyclic directed graph

I have a cyclic directed graph. Starting at the leaves, I wish to propagate data attached to each node downstream to all nodes that are reachable from that node. In particular, I need to keep pushing data around any cycles that are reached until the…
David Given
  • 13,277
  • 9
  • 76
  • 123
19
votes
3 answers

How can one create cyclic (and immutable) data structures in Clojure without extra indirection?

I need to represent directed graphs in Clojure. I'd like to represent each node in the graph as an object (probably a record) that includes a field called :edges that is a collection of the nodes that are directly reachable from the current node.…
Laurence Gonsalves
  • 137,896
  • 35
  • 246
  • 299
18
votes
5 answers

Is there a good graph layout library callable from C++?

The (directed) graphs represent finite automata. Up until now my test program has been writing out dot files for testing. This is pretty good both for regression testing (keep the verified output files in subversion, ask it if there has been a…
user180247
17
votes
9 answers

Algorithm to check if directed graph is strongly connected

I need to check if a directed graph is strongly connected, or, in other words, if all nodes can be reached by any other node (not necessarily through direct edge). One way of doing this is running a DFS and BFS on every node and see all others are…
Kazoom
  • 5,659
  • 16
  • 56
  • 69
15
votes
2 answers

Tarjan's strongly connected components algorithm in python not working

I implemented the Tarjan's strongly connected components algorithm, according to wikipedia, in Python, but it isn't working. The algorithm is quite short and I cannot find any difference, so I cannot tell why it isn't working. I tried to check the…
jmora
  • 491
  • 3
  • 14
15
votes
1 answer

How to remove cycles in an unweighted directed graph, such that the number of edges is maximised?

Let G be an unweighted directed graph containing cycles. I'm looking for an algorithm which finds/creates all acyclic graphs G', composed of all vertices in G and a subset of edges of G, just small enough to make G' acyclic. More formal: The desired…
mtsz
  • 2,725
  • 7
  • 28
  • 41
15
votes
5 answers

Free C++ library for drawing flow diagrams or Directed graph?

I want to embed a flow diagram drawing canvas in my program. Users would possible to: draw "nodes" (rectangle nodes is enough) and "edges" (preferable to be orthogonal) to connect "nodes"; use mouse to drag nodes for layout and resize…
Zhang Long
  • 151
  • 1
  • 1
  • 6
15
votes
4 answers

Directed probability graph - algorithm to reduce cycles?

Consider a directed graph which is traversed from first node 1 to some final nodes (which have no more outgoing edges). Each edge in the graph has a probability associated with it. Summing up the probabilities to take each possible path towards all…
Kagaratsch
  • 963
  • 8
  • 18
15
votes
6 answers

What is the most efficient way to determine if a directed graph is singly connected?

I am working on an assignment where one of the problems asks to derive an algorithm to check if a directed graph G=(V,E) is singly connected (there is at most one simple path from u to v for all distinct vertices u,v of V. Of course you can brute…
zebraman
  • 2,424
  • 5
  • 20
  • 21
15
votes
2 answers

Algorithm for topological sorting if cycles exist

Some programming languages (like haskell) allow cyclic dependencies between modules. Since the compiler needs to know all definitions of all modules imported while compiling one module, it usually has to do some extra work if some modules import…
fuz
  • 88,405
  • 25
  • 200
  • 352
13
votes
3 answers

Edge classification during Breadth-first search on a directed graph

I am having difficulties finding a way to properly classify the edges while a breadth-first search on a directed graph. During a breadth-first or depth-first search, you can classify the edges met with 4 classes: TREE BACK CROSS FORWARD Skiena…
12
votes
2 answers

How do I find all paths through a set of given nodes in a DAG?

I have a list of items (blue nodes below) which are categorized by the users of my application. The categories themselves can be grouped and categorized themselves. The resulting structure can be represented as a Directed Acyclic Graph (DAG) where…
Hanno Fietz
  • 30,799
  • 47
  • 148
  • 234
12
votes
1 answer

Solving dependency constraints

I have a classic dependency solving problem. I thought I was headed in the right direction, but now I've hit a roadblock and I am not sure how to proceed. Background In the known universe (the cache of all artifacts and their dependencies), each…
sethvargo
  • 26,739
  • 10
  • 86
  • 156
1
2
3
45 46