libDAI
|
This example deals with the following bipartite graph:
It has three nodes of type 1 (drawn as circles) and two nodes of type 2 (drawn as rectangles). Node 0 of type 1 has only one neighbor (node 0 of type 2), but node 0 of type 2 has three neighbors (nodes 0,1,2 of type 1). The example code shows how to construct a BipartiteGraph object representing this bipartite graph and how to iterate over nodes and their neighbors.
G has 3 nodes of type 1, 2 nodes of type 2 and 5 edges. Node 0 of type 1 has 1 neighbors: the 0'th neighbor is node 0 of type 2 Node 1 of type 1 has 2 neighbors: the 0'th neighbor is node 0 of type 2 the 1'th neighbor is node 1 of type 2 Node 2 of type 1 has 2 neighbors: the 0'th neighbor is node 0 of type 2 the 1'th neighbor is node 1 of type 2