directed-graph

Generate all possible subgraphs of a directed graph keeping the number of vertices

我怕爱的太早我们不能终老 提交于 2019-12-06 05:07:29
I have two lists of vertices: V and S . I would like to generate all possible directed graphs from V and S so, that each vertex from V has only one out-edge and exactly one in-edge, and each vertex from S can have any number of in- and out- edges. Each graph in the result should contain exactly all vertices from V and from S . The result can contain both connected and disconnected graphs. First I thought it was a powerset-related problem, but powerset has many other sets that may contain just one element (and I do not need those). My current strategy is to: find all pairs between vertices from

What if I do not use G transpose in calculating Strongly Connected Components?

不问归期 提交于 2019-12-06 04:47:22
I am reading Introduction to Algorithms. In 22.5 Strongly Connected Component, the algorithm STRONGLY-CONNECTED-COMPONENT(G) is defined as: Call DFS(G) to compute finishing times u.f for each vertex u Compute G transpose Call DFS(G transpose), but in the main loop of DFS, consider the vertices in order of decreasing u.f(as computed in line 1) Output the vertices of each tree in the depth-first forest formed in line 3 as a separate strongly connected component If I change the alogrithm to just using G, without calculating G transpose. Also consider the vertices in order of Increasing u.f

Finding all the roots in a directed graph

孤者浪人 提交于 2019-12-06 03:29:43
问题 I need to find an algorithm for finding all the roots in a directed graph, in O(n+m). I have an algorithm for finding a single root: Run DFS(v) on some v in V. If the result is a single spanning tree, then v is a root. Otherwise, the result is a forest of trees. Then: Run DFS(u) on the root of the last tree. If the result is a single spanning tree, then u is a root. Else, there are no roots in the graph. Now if I want to find all the roots, is the best way to just run the above algorithm O(n)

Cycle detection in a graph

筅森魡賤 提交于 2019-12-06 00:04:41
问题 We are given a graph with the following facts: edge(a,b) edge(a,c) edge(b,a) edge(c,d) edge(d,d) edge(d,e) edge(e,f) edge(f,g) edge(g,e) And we are asked to define a rule, cycle(X) , that determines if there is a cycle starting from the node X . I am really lost on how to do this, I tried attempting to traverse the nodes and checking if the next one would be the starting one again but I cannot seem to get it to work 回答1: Archie's idea is a good starting point, but it will create an infinite

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

你。 提交于 2019-12-05 19:15:40
问题 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 edges. A path is acyclic if no edge occurs twice in it. My graphs (empirical datasets) have only between 20-160 nodes, however, some of them have many cycles in them, therefore there will be a very large number of paths, and my naive approach is simply

How to do directed graph drawing in PHP?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 06:52:36
I'm looking for a way to draw directed graphs in PHP. (as in http://upload.wikimedia.org/wikipedia/commons/0/08/Directed_acyclic_graph.png ). I want it to create an image of the graph just like GD can output an image. I've googled a lot on this, but I only can find a lot of libraries for drawing graphs in general (with bars etc), not directed graphs. P.S. I've tried using dot (the linux program) via system(), but unfortunately I have no permission to do that on the server. Also, I have no rights to install PHP extensions and stuff like that on the server, so it should work with normal PHP

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

佐手、 提交于 2019-12-05 01:34:05
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 { rankdir="LR"; LEFT->RIGHT; clusterrank="local"; subgraph cluster1 { rankdir="TB"; node[style=filled]; color=black; TOP->BOTTOM; } } Is there some other syntax to get a Top/Bottom and Left/Right graph in the same diagram, or is this not possible? Seems like this is a long standing feature request: http://www.graphviz.org/bugs/b1279.html Desperately wanting

How to plot a directed Graph in R with networkD3?

99封情书 提交于 2019-12-04 17:11:45
when I am ploting a directed graph with NetworkD3 , The edges are not directed , how can I fix it ? an Example : library(networkD3) data(MisLinks) data(MisNodes) forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8) I want the result to be directed This is the definetion of directed Graph: "A directed graph is graph, i.e., 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

D3 Directed graphs

谁说我不能喝 提交于 2019-12-04 12:25:00
问题 I have used the following example to generate directed graphs http://bl.ocks.org/1153292 I want to add a click event so that when the user clicks on a node, the heading of the node is displayed So far i did this var circle = svg.append("svg:g").selectAll("circle") .data(force.nodes()) .enter().append("svg:circle") .attr("r", 6) **.on("mouseup", disp)** .call(force.drag); ; function disp() { alert("Display the heading of the node clicked here"); }; Please advise me how to display that 回答1: You

Enumerating All Minimal Directed Cycles Of A Directed Graph

匆匆过客 提交于 2019-12-04 11:46:01
I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the Tarjan algorithm outputs. For instance, for the directed graph at this wikipedia page , I would like to get c <-> d and d <-> h as two separated directed cycles. I don't if this problem is polynomial or not. I ran over a paper "Enumerating Minimal Dicuts and Strongly Connected Subgraphs" that seems to conclude that this problem is incremental polynomial (I don't know what it means), but I am unable