bipartite

Minimizing number of crossings in a bipartite graph

心不动则不痛 提交于 2019-12-21 03:59:25
问题 The following algorithm problem occurred to me while drawing a graph for something unrelated: We have a plane drawing of a bipartite graph, with the disjoint sets arranged in columns as shown. How can we rearrange the nodes within each column so that the number of edge crossings is minimized? I know this problem is NP-hard for general graphs (link), but is there some trick considering that the graph is bipartite? As a follow-up, what if there is a third column w , which only has edges to v ?

Detect if a graph is bipartite using union find (aka disjoint sets)

孤人 提交于 2019-12-20 07:48:47
问题 I'm doing a problem on Spoj that basically reduces to detecting if a graph is bipartite. I'm trying to just color the graph using dfs, but it is too slow. Some guy comments this No bfs, no dfs, no bipartie graph. Simple Union-Find Set would make it (with speed, indeed). Hint #1: Cycle of even length does not affect the divisibility by 2 ( wow, so many i in a word ) of length of paths between two node. Hint #2: (SPOILER) let dist[i] be the distance of a path from i to parent[i]. update it with

Best matching in a bipartite graph (e.g.associating labels with points on a plot)

北慕城南 提交于 2019-12-20 01:08:11
问题 I am trying to extract semantics from graphical xy plots where the points are plotted and some or all have a label. The label is plotted "near the point" so that a human can normally understand which label goes with which point. For example in this plot it is clear which label(number) belongs to which point(*) and an algorithm based on Euclidian distance would work. (The labels and points have no semantic ordering - e.g. a scatterplot) *1 *2 *3 *4 In congested plots the authoring software

Combinatorics in Python

自闭症网瘾萝莉.ら 提交于 2019-12-19 03:16:29
问题 I have a sort of a one level tree structure as: Where p are parent nodes, c are child nodes and b are hypothetical branches. I want to find all combinations of branches under the constraint that only one parent can branch to only one child node, and two branches can not share parent and/or child. E.g. if combo is the set of combinations: combo[0] = [b[0], b[3]] combo[1] = [b[0], b[4]] combo[2] = [b[1], b[4]] combo[3] = [b[2], b[3]] I think that's all of them. =) How can this be achived

How to plot a bipartite graph in R

≡放荡痞女 提交于 2019-12-18 12:36:08
问题 How do I plot a network of type bipartite in R? Similar to this: I have similar data but with weights for both genes and diseases and SARS. This network is an example. I have different kind of attributes. I followed a link here. But due to my little knowledge in this topic, I could not get much out of it. Thanks in advance for any help. 回答1: From the ?bipartite_graph help: Bipartite graphs have a type vertex attribute in igraph, this is boolean and FALSE for the vertices of the first kind and

How to find if a graph is bipartite?

◇◆丶佛笑我妖孽 提交于 2019-12-18 11:26:30
问题 I have been trying to understand the bipartite graph. To my understanding it is a graph G which can be divided into two subgraphs U and V.So that intersection of U and V is a null set and union is graph G. I am trying to find if a graph is bipartite or not using BFS. Still it is not clear to me that how can we find this using BFS. Let us say we have graph defined as below. a:e,f b:e c:e,f,h d:g,h e:a,b,c f:a,c,g g:f,d h:c,d What i need here is step by step explanation of how this graph is a

Split vertices of disconnected bipartite graph equally

℡╲_俬逩灬. 提交于 2019-12-13 00:14:23
问题 I'm given a graph with many seperate components. Each component is bipartite. How do I distribute the vertices into two sets A and B such that the difference between the two sets is minimal ? Example: 1: 1 -> 2 ->3 -> 4 -> 5 2: 6 -> 7 -> 8 The best solution is A = {1, 3, 5, 7} B = {2, 4 ,6, 8} The other (non-optimal) solution is A = {1, 3, 5, 6, 8} B = {2, 4, 7} How do you solve this when the graph has many seperate bipartite components ? 回答1: It's the Partition Problem, slightly disguised.

Networkx bipartite graphs: nodes of different sets with the same number

六眼飞鱼酱① 提交于 2019-12-12 02:18:44
问题 I encountered a major problem while constructing a bipartite graph with Networkx. I take the nodes from a 2-columns csv, say CODINV2;APPLN_ID 1;3 1;4 1;5 2;3 2;6 3;6 4;12 After moving each column into a separate list the code to store the nodes is G=nx.Graph() G.add_nodes_from(codinv, bipartite=0) G.add_nodes_from(app_id, bipartite=1) Then i add the edges (based on the csv rows): for index,row in appl.iterrows(): G.add_edge(row['APPLN_ID'], row['CODINV2']) Now the links are actually created,

igraph package in RStudio: Bipartite graph projection error

纵饮孤独 提交于 2019-12-11 09:54:24
问题 In an attempt to learn the "nuts-and-bolts" of social network theory within the igraph package in R, I created a basic toy example of a bipartite graph of terror attacks during a single year of the Algerian Civil War. The vertices consist of terror perpetrators and targets, while the edges represent which group attacked which target. I can plot the general unipartite graph of this relationship (as well as basic analyses of network centrality), but am having problems creating a bipartite

Error in rowSums(x) : 'x' must be an array of at least two dimensions (Vegan:oecosimu)

北慕城南 提交于 2019-12-11 09:28:13
问题 I am trying to use the application oecosimu in Vegan package. library(sna) library(permute) library(lattice) library(vegan) library(bipartite) bio<-read.csv("/home/vicar66/Raw_data/Jan12/98percents_April_16/otu_table/Chapter1/no_bloom_bio_data_L3.txt") rownames(bio)<-bio[,1] bio[,1]<-NULL bio_m<-as.matrix(bio) a<-oecosimu(bio_m,bipartite::C.score,"swap") but I keep having this error message: Attaching package: 'bipartite' The following object is masked from 'package:vegan': nullmodel Error in