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

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

4

1 回答 1

1

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

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

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

于 2014-09-21T21:16:50.117 回答