graph-theory

Basic questions about nested blockmodel in graph-tool

只愿长相守 提交于 2019-12-04 23:19:10
问题 Very briefly, two-three basic questions about the minimize_nested_blockmodel_dl function in graph-tool library. Is there a way to figure out which vertex falls onto which block? In other words, to extract a list from each block, containing the labels of its vertices. The hierarchical visualization is rather difficult to understand for amateurs in network theory, e.g. are the squares with directed edges that are drawn meant to implicate the main direction of the underlying edges between two

How to efficiently calculate triad census in undirected graph in python

◇◆丶佛笑我妖孽 提交于 2019-12-04 22:53:32
I am calculating triad census as follows for my undirected network . import networkx as nx G = nx.Graph() G.add_edges_from( [('A', 'B'), ('A', 'C'), ('D', 'B'), ('E', 'C'), ('E', 'F'), ('B', 'H'), ('B', 'G'), ('B', 'F'), ('C', 'G')]) from itertools import combinations #print(len(list(combinations(G.nodes, 3)))) triad_class = {} for nodes in combinations(G.nodes, 3): n_edges = G.subgraph(nodes).number_of_edges() triad_class.setdefault(n_edges, []).append(nodes) print(triad_class) It works fine with small networks. However, now I have a bigger network with approximately 4000-8000 nodes. When I

How to find mother vertex in a directed graph in O(n+m)? [closed]

家住魔仙堡 提交于 2019-12-04 22:37:38
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last month . A mother vertex in a directed graph G = (V,E) is a vertex v such that all other vertices G can be reached by a directed path from v Give an O(n+m) algorithm to test whether graph G contains a mother vertex. (c) from Skiena manual Found only O(n(n+m)) way 回答1: Algorithm:: a) Do DFS

Using hypergraphs in pygraph, need verification that example is correct

旧街凉风 提交于 2019-12-04 21:56:19
I am trying to get my head around using hypergraphs in pygraph, the following is a simple example I inserted: hgr = hypergraph() hgr.add_nodes(["A1", "B1", "C1", "D1"]) hgr.add_nodes(["A2", "B2", "C2", "D2"]) hgr.add_nodes(["A3", "B3", "C3", "D3"]) hgr.add_nodes(["A4", "B4", "C4", "D4"]) hgr.add_hyperedge(("A1", "A2", "A3", "A4")) hgr.add_hyperedge(("B1", "B2", "B3", "B4")) hgr.add_hyperedge(("C1", "C2", "C3", "C4")) hgr.add_hyperedge(("D1", "D2", "D3", "D4")) h_dot = write(hgr) h_gvv = gv.readstring(h_dot) gv.layout(h_gvv,'dot') gv.render(h_gvv, 'png', 'hypergraph.png') The image I am getting

algorithm to enumerate all possible paths

三世轮回 提交于 2019-12-04 20:59:10
问题 Consider the following graph: I'm trying to find a way to enumerate all possible paths from a source node to a target node. For example, from A to E, we have the following possible paths: A B C D E A B C E A C D E A C E Note that for A C D E, there are actually 2 paths, since one of the paths uses edge F3 and the other uses edge F5. Also, since there's a cycle between A and C, you could end up with an infinite number of paths, but for the purposes of this I'm only interested in paths in which

Are there any online algorithms for planarity testing?

眉间皱痕 提交于 2019-12-04 20:16:05
问题 I know that planarity testing can be done in O(v) (equivalently O(e), since planar graphs have O(v) edges) time. I wonder if it can be done online in O(1) amortized time as each edge is added (still O(e) time overall). In other words, in a database table representing edges of a graph and subject to a constraint that the represented graph is planar, how much time must the DBMS responsible for managing the constraint take to validate each proposed insertion? (For simplification, assume that

Will a source-removal sort always return a maximal cycle?

≡放荡痞女 提交于 2019-12-04 19:07:46
I wrote a source-removal algorithm to sort some dependencies between tables in our database, and it turns out we have a cycle. For simplicity, let's say we have tables A, B, C, and D. The edges are like this: (A, B) (B, A) (B, C) (C, D) (D, A) As you can see, there are two cycles here. One is between A and B and another is between all four of them. Will this type of sort always choke on the largest cycle? Or is that not necessarily the case? By source-removal I presume you mean at each step removing a node with no incoming edges. What I think you are asking for is finding the maximal Euler

What are strongly connected components used for?

 ̄綄美尐妖づ 提交于 2019-12-04 16:16:27
问题 I have found several algorithms that explain how to find strongly connected components in a directed graph, but none explain why you would want to do this. What are some applications of strongly connected components? 回答1: You should check out Tim Roughgarden's Introduction to Algorithms course on Coursera. For every algorithm he goes over, he explains some applications of it. Very useful, and makes one see the value of studying algorithms! The use of strongly connected components that I

Find a line passing the maximum number of points [closed]

☆樱花仙子☆ 提交于 2019-12-04 14:36:03
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I found a Google Interview question on CareerCup Given a 2D plane, suppose that there are around 6000 points on it. Find a line which passes the most number of points. Many answers there say this question is hard and involving some kind

Java library for graphs

社会主义新天地 提交于 2019-12-04 12:29:41
what is the best Java library for manipulating graphs (specifically, for social network analysis)? I've seen Jung, but I was wondering if you knew anything better (I don't need to visualize networks, only computation). Thank you I've found jgrapht pretty useful - it has all the major algorithms (e.g. Bellman-Ford, ...) neo4j is the choice And here is a video If you are aiming for high efficiency http://grph.inria.fr/ 来源: https://stackoverflow.com/questions/4362219/java-library-for-graphs