Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #23275: Bipartite graphs should not accept loops
Loops should not be allowed in a bipartite graph, but we can currently do: {{{ sage: B = BipartiteGraph(loops=True, multiedges=True) sage: B.add_edge(0, 0) sage: B.is_bipartite() False sage: B.add_edge(1, 1) sage: B.add_edge(2, 2) sage: B.edges(labels=0) [(0, 0), (1, 1), (2, 2)] sage: B.add_edge(0, 1, 'a') ------------------------------------------------------------------------ --- RuntimeError Traceback (most recent call last) ... RuntimeError: Edge vertices must lie in different partitions. sage: B.add_edge(3, 3) sage: B.edges() [(0, 0, None), (1, 1, None), (2, 2, None), (3, 3, None)] }}} When adding edges in a different order, the behavior is more consistent. {{{ sage: B = BipartiteGraph(loops=True, multiedges=True) sage: B.add_edge(0, 1, 'a') sage: B.add_edge(0, 1, 'b') sage: B.is_bipartite() True sage: B.add_edge(0,0) ------------------------------------------------------------------------ --- RuntimeError Traceback (most recent call last) ... RuntimeError: Edge vertices must lie in different partitions. }}} URL: https://trac.sagemath.org/23275 Reported by: dcoudert Ticket author(s): David Coudert Reviewer(s): Zachary Gershkoff
- Loading branch information