edges

R igraph convert parallel edges to weight attribute

天大地大妈咪最大 提交于 2019-12-18 19:08:44
问题 I'm working with igraph for R. My graph is based on an edgelist which includes parallel edges (more than one edge with the same source and target). I would like to convert these parallel edges to an edge attribute weight. Is there an eay way to do this? If there is no easy way. how can I identify these parallel edges? duplicated(E(net)) does not return a single duplicate. I suppose its looking for duplicated edge ids. 回答1: You can also use E(graph)$weight <- 1 followed by simplify(graph, edge

Implementing Depth First Search into C# using List and Stack

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 17:32:51
问题 I want to create a depth first search which I have been somewhat successful in. Here is my code so far (Except my constructor, note the Vertex and Edge classes only contain properties, nothing important to post here): private Stack<Vertex> workerStack = new Stack<Vertex>(); private List<Vertex> vertices = new List<Vertex>(); private List<Edge> edges = new List<Edge>(); private int numberOfVertices; private int numberOfClosedVertices; private int visitNumber = 1; private void StartSearch() { /

GraphViz, grouping the same edges

孤人 提交于 2019-12-17 16:26:57
问题 digraph G { a -> b [ label = "foo" ]; a -> b [ label = "bar" ]; } This will create two edges between the 'a' and 'b' nodes. Is there a way to have only one edge (group them)? 回答1: I think it really depends on what your desired output would be. One possibility is: digraph G { graph [ splines = false ] a -> b [ label = "foo" ]; a -> b [ label = "bar" ]; } Where not using splines draws edges with straight line segments and so duplicate edges will not be distinguished visually. In your ideal

Drawing multiple edges between two nodes with d3

元气小坏坏 提交于 2019-12-17 06:38:13
问题 I've been following Mike Bostock's code from this example to learn how to draw directed graphs in d3 and was wondering how I would structure the code so that I could add multiple edges between two nodes in the graph. For example, if the dataset in the example above were defined as var links = [{source: "Microsoft", target: "Amazon", type: "licensing"}, {source: "Microsoft", target: "Amazon", type: "suit"}, {source: "Samsung", target: "Apple", type: "suit"}, {source: "Microsoft", target:

Find array of edges with imageJ

[亡魂溺海] 提交于 2019-12-13 08:25:13
问题 I have already found edges of an image thanks to imageJ library. Now, I'd like to get an array which would contain these edges. There is a topic about it here but i couldn't comment and there wasn't the answer: Find Edges with ImageJ Programmatically 回答1: As documented in §29.3 Find Edges, the command uses the Sobel operator. Each point of the final image is the magnitude of the gradient of the horizontal and vertical convolutions. A copy of the whole array is returned by the get*Array()

copying edges with adjacent vertices and their properties using BOOST

北战南征 提交于 2019-12-13 07:49:05
问题 I'm trying to copy an edge from a graph and add it to another (with all his vertices and properties), I make something like: if (!dataG.empty()) { auto const& gr = dataG.front(); // firslt graph in G_list auto ep = edges(gr).first; //first edge in gr vertex_t from = source(*ep, gr); vertex_t to = target(*ep, gr); boost::property_map<Graph, int VertexProperties::*>::type idmap = boost::get(&VertexProperties::id, testg); boost::property_map<Graph, int VertexProperties::*>::type labelmap = boost

NetworkX: connect nodes of two separate graphs in Python

空扰寡人 提交于 2019-12-12 21:42:03
问题 This question is about attempting to model interdependent networks with NetworkX. There are dedicated packages (such as Pymnet), but they don't seem as flexible as NetworkX. And by the way, I wanted to give NetworkX one last chance. So, let's say we have 2 separate graphs, G1 and G2, which we plot in the same figure: import networkx as nx import matplotlib.pyplot as plt G1=nx.barabasi_albert_graph(3, 2) #n=3, m=2 (number of initial links) G2=nx.barabasi_albert_graph(3, 2) pos1=nx.spring

JGraphx : How to avoid adding edges over each other?

走远了吗. 提交于 2019-12-12 10:24:01
问题 I'm working on an application using jGraphx and I want to know how to avoid creating edges over each other. When I add 2 edges between 2 vetexes, the 2 edges are above eatch other.. Thanks in advance. EDIT : That's what I get, those are 2 edges with the labels : "dist = 1" and "dist = 4" above each other. 回答1: It can be done easily: new mxCircleLayout(graph).execute(graph.getDefaultParent()); new mxParallelEdgeLayout(graph).execute(graph.getDefaultParent()); 回答2: Without seeing any of your

D3.js Edge Bundling without Hierachy

无人久伴 提交于 2019-12-12 03:14:11
问题 Holten's hierarchical edge bundling algorithm in D3 depends on hierarchical data. Example: http://bl.ocks.org/mbostock/7607999 Is there a way to implement a similar circular edge bundling graph with those nice splines for non-hierarchical data? Example: http://bl.ocks.org/sjengle/5432087 (Like this, but with splines...) 回答1: If your data really is non-hierarchical, you could change the drawCurves function of your example into something like this: function drawCurves(links) { d3.select("#plot"

Python: edge length distribution of a regular network

落花浮王杯 提交于 2019-12-12 02:37:13
问题 I am working with an NxN regular network and I want to plot its edge length distribution . This is how I generate the network: import networkx as nx import matplotlib.pyplot as plt N=30 #This can be changed G=nx.grid_2d_graph(N,N) pos = dict( (n, n) for n in G.nodes() ) labels = dict( ((i, j), i + (N-1-j) * N ) for i, j in G.nodes() ) nx.relabel_nodes(G,labels,False) inds=labels.keys() vals=labels.values() inds.sort() vals.sort() pos2=dict(zip(vals,inds)) nx.draw_networkx(G, pos=pos2, with