def _marriage_graph(g): '''Return an extended pedigree graph that includes marriage nodes and edges. Marriage node IDs are negative to avoid collision with real nodes.''' h = nx.DiGraph() h.add_nodes_from(g.nodes_iter()) h.add_edges_from(g.edges_iter()) marriage = -1 # for (parents, children) in pt.families(g): h.add_edges_from((parent, marriage) for parent in parents) h.add_edges_from((marriage, child) for child in children) h.remove_edges_from((parent, child) for parent in parents for child in children) marriage -= 1 return h
def _marriage_graph(g): '''Return an extended pedigree graph that includes marriage nodes and edges. Marriage node IDs are negative to avoid collision with real nodes.''' h = nx.DiGraph() h.add_nodes_from(g.nodes_iter()) h.add_edges_from(g.edges_iter()) marriage = -1 # for (parents, children) in pt.families(g): h.add_edges_from((parent, marriage) for parent in parents) h.add_edges_from((marriage, child) for child in children) h.remove_edges_from( (parent, child) for parent in parents for child in children) marriage -= 1 return h
def test_families(self): '''Test family computation.''' p = io_pedigree.read(itu.HUTT_PED) assert_equal(len(list(pt.families(p.graph))), 990, 'Wrong number of pedigree families')