Consider this simple, bipartite graph in GraphML:
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="type" for="node" attr.name="type" attr.type="boolean">
<default>TRUE</default>
</key>
<graph id="G" edgedefault="directed">
<node id='p1'><data key='type'>FALSE</data></node>
<node id='o1'></node>
<node id='o2'></node>
<edge id='e1' source='p1' target='o1'></edge>
<edge id='e2' source='p1' target='o2'></edge>
</graph>
</graphml>
Now consider this R session:
require("igraph")
graph <- read.graph(file="bipartitetest.graphml",format="graphml")
proj <- bipartite.projection(graph)
Although the graph object seems fine:
graph
IGRAPH D--B 3 2 --
+ attr: type (v/l), id (v/c), id (e/c)
my igraph version 0.7.1 complains:
Error in .Call("R_igraph_bipartite_projection", graph, types, as.integer(probe1), :
At bipartite.c:198 : Non-bipartite edge found in bipartite projection, Invalid value
Why is that? The simple graph seems to be valid a-priori.
This is probably an igraph bug, but seemingly it ignores the default value of the type
attribute:
V(graph)$type
# [1] FALSE FALSE FALSE
The workaround is to specify it explicitly, until the bug is fixed.