graph-theory

How do I show edge labels on graphs?

空扰寡人 提交于 2019-12-30 05:08:35
问题 I am trying to load a gexf file with sigInst.parseGexf('data/test.gexf'). To create an edge with label I have this line in gexf file: <edge label="test" id="7" source="14" target="18" type="directed"/> but seems that sigma.js ignore this label field. How can I show edge labels in graphs? 回答1: It's not yet possible with the main sigma.js library. However, I just forked the repository and added the capability on github.com here: https://github.com/sam2themax/sigma.js To enable this new feature,

minimum connected subgraph containing a given set of nodes

一世执手 提交于 2019-12-30 02:44:06
问题 I have an unweighted, connected graph. I want to find a connected subgraph that definitely includes a certain set of nodes, and as few extras as possible. How could this be accomplished? Just in case, I'll restate the question using more precise language. Let G(V,E) be an unweighted, undirected, connected graph. Let N be some subset of V. What's the best way to find the smallest connected subgraph G'(V',E') of G(V,E) such that N is a subset of V'? Approximations are fine. 回答1: I can't think

Difference between hamiltonian path and euler path

為{幸葍}努か 提交于 2019-12-29 10:13:27
问题 Can some one tell me the difference between hamiltonian path and euler path. They seem similar! 回答1: An Euler path is a path that passes through every edge exactly once. If it ends at the initial vertex then it is an Euler cycle . A Hamiltonian path is a path that passes through every vertex exactly once (NOT every edge). If it ends at the initial vertex then it is a Hamiltonian cycle . In an Euler path you might pass through a vertex more than once. In a Hamiltonian path you may not pass

small cycle finding in a planar graph

落花浮王杯 提交于 2019-12-29 05:24:07
问题 I have a geometric undirected planar graph, that is a graph where each node has a location and no 2 edges cross, and I want to find all cycles that have no edges crossing them. Are there any good solutions known to this problem? What I'm planning on doing is a sort of A* like solution: insert every edge in a min heap as a path extend the shortest path with every option cull paths that loop back to other than there start (might not be needed) cull paths that would be the third to use ang given

Finding Center of The Tree

雨燕双飞 提交于 2019-12-29 05:22:07
问题 I have a question which is part of my program. For a tree T=(V,E) we need to find the node v in the tree that minimize the length of the longest path from v to any other node. so how we find the center of the tree? Is there can be only one center or more? If anyone can give me good algorithm for this so i can get the idea on how i can fit into my program. 回答1: Consider a tree with two nodes? Which is the center? Either one will suffice, ergo a tree can have more than one center. Now, think

All minimum spanning trees implementation

本小妞迷上赌 提交于 2019-12-28 12:16:27
问题 I've been looking for an implementation (I'm using networkx library.) that will find all the minimum spanning trees (MST) of an undirected weighted graph. I can only find implementations for Kruskal's Algorithm and Prim's Algorithm both of which will only return a single MST. I've seen papers that address this problem (such as Representing all minimum spanning trees with applications to counting and generation) but my head tends to explode someway through trying to think how to translate it

Finding connected components of adjacency matrix graph

耗尽温柔 提交于 2019-12-28 05:23:32
问题 I have a random graph represented by an adjacency matrix in Java, how can I find the connected components (sub-graphs) within this graph? I have found BFS and DFS but not sure they are suitable, nor could I work out how to implement them for an adjacency matrix. Any ideas? 回答1: You need to allocate marks - int array of length n, where n is the number of vertex in graph and fill it with zeros. Then: 1) For BFS do the following: Components = 0; Enumerate all vertices, if for vertex number i,

Finding All Cliques of an Undirected Graph

旧巷老猫 提交于 2019-12-25 18:24:25
问题 How can I list all cliques of an Undirected Graph ? (Not all maximal cliques, like the Bron-Kerbosch algorithm) 回答1: The optimal solution is like this because in a complete graph there are 2^n cliques. Consider all subsets of nodes using a recursive function. And for each subset if all the edges are present between nodes of the subset, add 1 to your counter: (This is almost a pseudocode in C++) int clique_counter = 0; int n; //number of nodes in graph //i imagine nodes are numbered from 1 to

Use equal vertex in a JGraphT SimpleGraph

跟風遠走 提交于 2019-12-25 12:09:52
问题 In Java, want to create a simple graph (a unweighted, undirected graph containing no graph loops or multiple edges) containing vertexes/edges that are equal. I have two Java Classes, one for the vertexes: class Vertex { private int field; public Vertex(int field) { this.field = field; } @Override public boolean equals(Object obj) { if (obj.getClass().getPackage() .equals(this.getClass().getPackage()) && obj.getClass().getName() .equals(this.getClass().getName())) { Vertex vertex = (Vertex)

Group a range of integers such as no pair of numbers is shared by two or more groups

走远了吗. 提交于 2019-12-25 09:30:12
问题 You are given two numbers, N and G. Your goal is to split a range of integers [1..N] in equal groups of G numbers each. Each pair of numbers must be placed in exactly one group. Order does not matter. For example, given N=9 and G=3, I could get these 12 groups: 1-2-3 1-4-5 1-6-7 1-8-9 2-4-6 2-5-8 2-7-9 3-4-9 3-5-7 3-6-8 4-7-8 5-6-9 As you can see, each possible pair of numbers from 1 to 9 is found in exactly one group. I should also mention that such grouping cannot be done for every possible