二分(双模)图的简单投影在igraph 0.7.1中不起作用



在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>

现在考虑这个R会话:

require("igraph")
graph <- read.graph(file="bipartitetest.graphml",format="graphml")
proj <- bipartite.projection(graph)

尽管图形对象看起来很好:

graph
IGRAPH D--B 3 2 -- 
+ attr: type (v/l), id (v/c), id (e/c)

我的igraph 0.7.1版本抱怨:

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

为什么?这个简单的图似乎是先验有效的。

这可能是一个igraph错误,但它似乎忽略了type属性的默认值:

V(graph)$type
# [1] FALSE FALSE FALSE

解决方法是明确指定它,直到修复错误为止。

最新更新