graph-theory

Graph dataset collection in igraph - not supported now - what is easy way to get these graph to Python?

江枫思渺然 提交于 2021-01-29 10:09:15
问题 The previous versions of powerful graph library "igraph" contained a collection of datasets, in particular: > "immuno" Immunoglobulin interaction network > "macaque" Visuotactile brain areas and connections > "rfid" Hospital encounter network data > "yeast" Yeast protein interaction network Now, unfortunately, these datasets are not supported (at least in Python version). Also repository "Nexus" for these data is not supported. Question: Is there a simple way to find/work with these graphs in

Java: Iterator is supposed to always return the same object, but should change it between calls of next()

邮差的信 提交于 2021-01-29 09:36:49
问题 The Iterator I'm writing is supposed to iterate through all fixed-sized connected subgraphs of another given graph. As these subgraphs are all very similar (only minor changes in a search-tree based algorithm), I don't want to create a new object to return on each call of next() because of runtime concerns. Therefore I have an object subGraph that is returned every time, but is changed by a function update() between calls of next() , so that the object works like a view of the current state

Highlighting certain nodes/edges in NetworkX - Issues with using zip()

◇◆丶佛笑我妖孽 提交于 2021-01-28 03:59:46
问题 I able to populate network graph using networkx. My problem is when I want to highlight the path (shortest path for example) the graph cannot generate and it will return error below. nx.draw_networkx_edges(Gr,pos,edgelist=path_edges,edge_color='r',width=10) File "/usr/local/lib/python3.6/site-packages/networkx/drawing/nx_pylab.py", line 578, in draw_networkx_edges if not edgelist or len(edgelist) == 0: # no edges! TypeError: object of type 'zip' has no len() I look for solution and this is

Create matrix with same in and out degree for all nodes

邮差的信 提交于 2021-01-27 10:36:17
问题 I've stated this question in graph theory terms, but that conceptualization isn't necessary. What I'm trying to do, using Python, is produce a matrix of zeros and ones, where every row has the same number of ones and every column has the same number of ones. The number for rows will not be the same as the number for columns when the number of rows (sending nodes) does not equal the number of columns (receiving nodes) -- which is something I'm allowing. It makes sense to me to do this in numpy

Draw nodes in a graph clustered based on color

好久不见. 提交于 2021-01-15 10:08:46
问题 In the following dictionary mapping nodes to color, I wanted to draw the resultant graph whilst clustering the nodes within the graph based on their color. That is if node 4187 and 8285 have crimson color, I want them to appear next to each other on the graph. My dictionary is as follows: nodesWithGroup= {6: 'slateblue', 10: 'skyblue', 4109: 'lawngreen', 2062: 'mediumaquamarine', 28: 'olive', 10269: 'crimson', 6175: 'aqua', 10271: 'crimson', 36: 'mediumaquamarine', 2085: 'darkturquoise', 2084

Draw nodes in a graph clustered based on color

给你一囗甜甜゛ 提交于 2021-01-15 10:08:04
问题 In the following dictionary mapping nodes to color, I wanted to draw the resultant graph whilst clustering the nodes within the graph based on their color. That is if node 4187 and 8285 have crimson color, I want them to appear next to each other on the graph. My dictionary is as follows: nodesWithGroup= {6: 'slateblue', 10: 'skyblue', 4109: 'lawngreen', 2062: 'mediumaquamarine', 28: 'olive', 10269: 'crimson', 6175: 'aqua', 10271: 'crimson', 36: 'mediumaquamarine', 2085: 'darkturquoise', 2084

Bellman Ford and One Olympiad Questions?

时光怂恿深爱的人放手 提交于 2020-12-29 09:11:58
问题 I took an Olympiad Exam three days ago. I ran into a nice question as follows. We know the bellman-ford algorithm checks all edges in each step, and for each edge if, d(v)>d(u)+w(u,v) then d(v) being updated such that w(u,v) is the weight of edge (u, v) and d(u) is the length of best finding path for vertex u . if in one step we have no update for vertexes , the algorithms terminates . Supposing this algorithm for finding all shortest path from vertex s in graph G with n vertex after k < n

Bellman Ford and One Olympiad Questions?

筅森魡賤 提交于 2020-12-29 09:04:16
问题 I took an Olympiad Exam three days ago. I ran into a nice question as follows. We know the bellman-ford algorithm checks all edges in each step, and for each edge if, d(v)>d(u)+w(u,v) then d(v) being updated such that w(u,v) is the weight of edge (u, v) and d(u) is the length of best finding path for vertex u . if in one step we have no update for vertexes , the algorithms terminates . Supposing this algorithm for finding all shortest path from vertex s in graph G with n vertex after k < n

Maximum-weight independent set problem for a path graph

跟風遠走 提交于 2020-12-26 04:00:42
问题 While taking the Algorithms: Design and Analysis II class, one of the questions asks about the maximum-weight independent set problem for a path graph. shown below is a (blurry) screenshot of the problem statement, and the corresponding lecture videos are on YouTube: https://www.youtube.com/watch?v=0awkct8SkxA https://www.youtube.com/watch?v=pLOkbHGRsv0 https://www.youtube.com/watch?v=Im_zjFkZDCY This problem can be elegantly solved by dynamic programming, with literally one line of code. a[i

Maximum-weight independent set problem for a path graph

a 夏天 提交于 2020-12-26 03:57:19
问题 While taking the Algorithms: Design and Analysis II class, one of the questions asks about the maximum-weight independent set problem for a path graph. shown below is a (blurry) screenshot of the problem statement, and the corresponding lecture videos are on YouTube: https://www.youtube.com/watch?v=0awkct8SkxA https://www.youtube.com/watch?v=pLOkbHGRsv0 https://www.youtube.com/watch?v=Im_zjFkZDCY This problem can be elegantly solved by dynamic programming, with literally one line of code. a[i