# Meaning of "Non-bipartite edge found in bipartite projection" error

**URL:** <https://igraph.discourse.group/t/meaning-of-non-bipartite-edge-found-in-bipartite-projection-error/1252>\
**Category:** Usage\
**Tags:** R\
**Created:** [16 June 2022 19:32 UTC](https://igraph.discourse.group/t/meaning-of-non-bipartite-edge-found-in-bipartite-projection-error/1252 "2022-06-16T19:32:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nw2this](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@nw2this](https://igraph.discourse.group/u/nw2this)\
**Post date:** [16 June 2022 19:32 UTC](https://igraph.discourse.group/t/meaning-of-non-bipartite-edge-found-in-bipartite-projection-error/1252/1 "2022-06-16T19:32:57Z")

</div>

Any suggestions on what this error means or how to find which value is invalid?

Error in igraph::bipartite.projection(bg, which = FALSE) :  
At core/misc/bipartite.c:209 : Non-bipartite edge found in bipartite projection, Invalid value

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [16 June 2022 20:17 UTC](https://igraph.discourse.group/t/meaning-of-non-bipartite-edge-found-in-bipartite-projection-error/1252/2 "2022-06-16T20:17:37Z")

</div>

Please do not post unrelated responses to existing topics. Create a new topic with a meaningful title, and make sure you are doing it within an appropriate category.

The error means that there is at least one edge between vertices of the same partition. The partitions are defined by the `type` boolean vertex attribute: vertices within the first partition are marked with `FALSE`, those within the second with `TRUE`.

---

<div class="post-metadata">

**Author:** ![nw2this](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@nw2this](https://igraph.discourse.group/u/nw2this)\
**Post date:** [17 June 2022 14:57 UTC](https://igraph.discourse.group/t/meaning-of-non-bipartite-edge-found-in-bipartite-projection-error/1252/3 "2022-06-17T14:57:55Z")

</div>

Sorry, I couldn’t figure out how to post properly. I did look at “How to Post”, but it didn’t explain how to post. Could that link be wrong?

Is a partition the same as a mode? I have 2 modes (patients and hospitals), the patients in one column and hospitals in another. The ids for these are very different, so there is no way a hospital could be connected to a hospital or a patient to a patient. Although, that is my goal (to switch the 2 modes to one mode) using patients as connections between hospitals with number of patients as the weight.

Is there a way to figure out which value is invalid?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [17 June 2022 21:50 UTC](https://igraph.discourse.group/t/meaning-of-non-bipartite-edge-found-in-bipartite-projection-error/1252/4 "2022-06-17T21:50:01Z")

</div>

> [@nw2this](#):
>
> Is a partition the same as a mode?

Yes.

> [@nw2this](#):
>
> so there is no way a hospital could be connected to a hospital or a patient to a patient.

But that is precisely what is happening. Maybe the mistake is in marking nodes as hospital or patient.

> [@nw2this](#):
>
> Is there a way to figure out which value is invalid?

Take all vertices from one of the partitions and create an induced subgraph for them. Something along the lines of `induced_subgraph(g, V(g)[V(g)$type])`. This graph should have no edges.

---

<div class="post-metadata">

**Author:** ![nw2this](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@nw2this](https://igraph.discourse.group/u/nw2this)\
**Post date:** [21 June 2022 02:28 UTC](https://igraph.discourse.group/t/meaning-of-non-bipartite-edge-found-in-bipartite-projection-error/1252/6 "2022-06-21T02:28:01Z")

</div>

Thank you for your help. I removed dropped some data and now the following code is working.

```auto
bipartite_list <- data.frame(read.csv(file.choose()))
head(bipartite_list)
net <-graph.data.frame(bipartite_list, directed=F)
net
head(net)
bipartite.mapping(net)
V(net)$type <- bipartite_mapping(net)$type
size<- bipartite.projection.size(net)
size
head(size)
onemode <- project_table(bipartite_list, joining_col = "pat_id")
g_onemode <-graph.data.frame(onemode, directed=F)

```

I dropped some rows with low weight using this  
`few_edge <-delete.edges(g_onemode, which(E(g_onemode)$weight<1000))`  
but, when I try to graph this the weight is gone and I want edge width based on weight. How can I get weight back into this object?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [21 June 2022 07:52 UTC](https://igraph.discourse.group/t/meaning-of-non-bipartite-edge-found-in-bipartite-projection-error/1252/7 "2022-06-21T07:52:06Z")

</div>

Can you show a complete minimal example? See here for guidance: [How to create a Minimal, Reproducible Example - Help Center - Stack Overflow](https://stackoverflow.com/help/minimal-reproducible-example)
