directed-graph

Creating curved edges with NetworkX in Python3

谁说我不能喝 提交于 2020-05-27 01:51:48
问题 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 this: #!/usr/bin/env python3 import networkx as nx import matplotlib.pyplot as plt # Graph data names = ['A', 'B', 'C', 'D', 'E'] positions = [(0, 0), (0, 1), (1, 0), (0.5, 0.5), (1, 1)] edges = [('A', 'B'), ('A', 'C'), ('A', 'D'), ('A', 'E'), ('D', 'A')]

Creating curved edges with NetworkX in Python3

有些话、适合烂在心里 提交于 2020-05-27 01:49:19
问题 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 this: #!/usr/bin/env python3 import networkx as nx import matplotlib.pyplot as plt # Graph data names = ['A', 'B', 'C', 'D', 'E'] positions = [(0, 0), (0, 1), (1, 0), (0.5, 0.5), (1, 1)] edges = [('A', 'B'), ('A', 'C'), ('A', 'D'), ('A', 'E'), ('D', 'A')]

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

随声附和 提交于 2020-04-07 14:59:10
问题 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 algorithm consumes G and creates a set of acyclic graphs S, where each graph G' in S satisfies following properties: G' contains all vertices of G. G' contains a subset of edges of G, such that G' is acyclic. The number of edges of G' is maximised

How to plot a directed Graph in R with networkD3?

点点圈 提交于 2020-02-21 05:14:09
问题 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,

How to plot a directed Graph in R with networkD3?

半世苍凉 提交于 2020-02-21 05:12:11
问题 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,

Adding text labels to force directed graph links in d3.js

巧了我就是萌 提交于 2020-01-25 20:34:05
问题 I am having trouble adding a text to the links that connect the nodes in the following D3JS connected node graph: http://jsfiddle.net/rqa0nvv2/1/ Could anyone please explain to me what is the process to add them? var link = svg.selectAll(".link") .data(links) .enter().append("line") .attr("class", function(d) { if(d.value == "visible") {return "link";} else return "" }) .style("stroke-width", function(d) { return Math.sqrt(d.stroke); }); link.append("svg:title").text(function(d) { return

d3.js collapsible force layout with all the nodes collapsed

▼魔方 西西 提交于 2020-01-11 13:41:27
问题 I've been trying to implement a directed force layout using a json file that I've written. Before I tried to make it begin with all nodes collapsed, it was working properly. I've declared a property called "index" for all the nodes, indicating which level of the tree they belong (root's index is 0, it's children are 1, etc.) I'm guessing that there is a problem with "index" property of the nodes because when I first start my page their values are correct, but when I collapse and re-open one a

What is the number of all possible non-cyclic simple paths in a fully-connected directed graph?

橙三吉。 提交于 2020-01-03 04:25:09
问题 Let's say we have a fully connected digraph G with N vertices and M edges. How many edges does the graph have? Is it M = N^2 ? If we take one vertex and start visiting its neighbors in a 'depth-first search' manner and avoiding loops, how many non-cyclic simple paths will we get? For example, if we start from vertex 1 in a graph of 4 vertices, here are the paths: - 1 - 1,2 - 1,3 - 1,4 - 1,2,3 - 1,2,4 - 1,3,2 - 1,3,4 - 1,4,2 - 1,4,3 Is it N! or more for a graph with N vertices? I could not

Python NetworkX find a subgraph in a Directed Graph from a node as root

安稳与你 提交于 2020-01-02 19:16:49
问题 I am writing a code to extract information from a directed graph. This graph has cycles as well. For example, A->B->C->D A->E->F->A B->F->G From this graph, I want to create a sub graph or the list of the nodes, where the input would be any node, and output would be the graph where the input node is the root, or the list of the nodes that has all the child nodes ( till the end of the graph ) from the input nodes For example, in the above example, 1. If the input node is C, the output would be

A fast way to find connected component in a 1-NN graph?

☆樱花仙子☆ 提交于 2020-01-01 10:23:53
问题 First of all, I got a N*N distance matrix, for each point, I calculated its nearest neighbor, so we had a N*2 matrix, It seems like this : 0 -> 1 1 -> 2 2 -> 3 3 -> 2 4 -> 2 5 -> 6 6 -> 7 7 -> 6 8 -> 6 9 -> 8 the second column was the nearest neighbor's index. So this was a special kind of directed graph, with each vertex had and only had one out-degree. Of course, we could first transform the N*2 matrix to a standard graph representation, and perform BFS/DFS to get the connected components.