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
12
votes
6 answers

Best Way to Store/Access a Directed Graph

I have around 3500 flood control facilities that I would like to represent as a network to determine flow paths (essentially a directed graph). I'm currently using SqlServer and a CTE to recursively examine all the nodes and their upstream…
Michael Todd
  • 16,679
  • 4
  • 49
  • 69
12
votes
3 answers

Does the dot Directed Graph allow for subgraphs with a different rankdir?

Using the dot directed graph language, is it possible to create subgraphs with a different rankdir? I tried the following, which didn't work. Both graphs were left to right, despite the presence of rankdir="TB" in the subgraph. digraph g { …
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
11
votes
3 answers

What is the most standard file format and notation for persisting expressive directed graphs?

I am interested in persisting individual directed graphs. This question is not asking for a full-scale graph database solution, but for a document format that I can use to save and individual arbitrary directed graph. I don't know what notation…
smartcaveman
  • 41,281
  • 29
  • 127
  • 212
11
votes
2 answers

networkx: Draw text on edges

for my thesis I need to draw some probabilistic control flow graphs. i.e. control flow graphs with probabilities depicted on the edges. I found graph-tool which seems quite useful, since it can use deep-copies of existing graphs and my graphs are…
Dominik G
  • 1,459
  • 3
  • 17
  • 37
10
votes
3 answers

Fast algorithm for counting the number of acyclic paths on a directed graph

In short, I need a fast algorithm to count how many acyclic paths are there in a simple directed graph. By simple graph I mean one without self loops or multiple edges. A path can start from any node and must end on a node that has no outgoing…
Szabolcs
  • 24,728
  • 9
  • 85
  • 174
10
votes
3 answers

Plotting the degree distribution of a graph using nx.degree_histogram

I've tried to use the following code to plot the degree distribution of the networkx.DiGraph G: def plot_degree_In(G): in_degrees = G.in_degree() in_degrees=dict(in_degrees) in_values = sorted(set(in_degrees.values())) in_hist =…
Amit Mek
  • 105
  • 1
  • 1
  • 5
10
votes
3 answers

More efficiently compute transitive closures of each dependents while incrementally building the directed graph

I need to answer the question: given a node in a dependency graph, group its dependents by their own transitive dependents which would be impacted by a particular start node. In other words, given a node in a dependency graph, find the set of sets…
10
votes
2 answers

Graph value propagation algorithm

I've got a directed graph (N, A), where each node n[i] has a value v[i] and a threshold t[i]. For each arrow (n[i], n[j]), the invariant v[i] <= v[j] holds. I need to efficiently implement the following operations: increaseThreshold(i, x): Set t[i]…
maaartinus
  • 44,714
  • 32
  • 161
  • 320
10
votes
2 answers

Generating strongly-connected, uniformly-distributed, random di-graphs

So I've been building a program that uses Monte Carlo simulations to find properties of evolutionary graph theory. One of the key functions of this is to be able to generate uniformly-distributed random graphs, so that we can determine the…
dl101
  • 147
  • 4
10
votes
2 answers

Force-directed layout implementation in Java

I've been looking around for a Java implementation of the force-directed graph layout algorithm but got no fruits so far. Any help will be appreciated :)
Mαzen
  • 535
  • 2
  • 7
  • 14
9
votes
3 answers

Counting distinct undirected edges in a directed graph in SQL

Given a table holding edges in a directed graph like this: CREATE TABLE edges ( from_here int not null, to_there int not null ) What's the nicest way to get the number of distinct undirected links for a specific node? There aren't any…
mu is too short
  • 426,620
  • 70
  • 833
  • 800
9
votes
2 answers

Saving graphs in Haskell

I can easily define a datatype for a node of a directed graph. data Node = Node String [Node] derving (Show, Read) I can save the graph to a file using show function, then restore it using read. However, show will not cope with a cycle. Is there a…
luntain
  • 4,560
  • 6
  • 37
  • 48
9
votes
1 answer

Tarjan's strongly-connected components algorithm - why index in the back edge?

I'm studying Tarjan's algorithm for strongly-connected components and the way it works is clear to me. Anyway there's a line I don't understand: // Consider successors of v for each (v, w) in E do if (w.index is undefined) then // Successor w…
Dean
  • 6,610
  • 6
  • 40
  • 90
9
votes
3 answers

Storing a directed graph in google appengine datastore

I need to store a large and dynamic undirected graph in google appengine, what's the best way to do this? The graph representation must be able to support rapidly pulling out a set of vertices (for rendering on a page) and all the links from a…
Martin
  • 12,469
  • 13
  • 64
  • 128
8
votes
2 answers

Data structure for directed graphs, allowing fast node deletion?

I need to store a directed graph (not necessarily acyclic), so that node deletion is as fast as possible. I wouldn't mind storing additional data in order to know exactly which edges have to go when a node is deleted. If I store a list of edges (as…
Amenhotep
  • 920
  • 1
  • 13
  • 18
1 2
3
45 46