Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta ticket: Finish bipartite graph implementation #1941

Open
rlmill mannequin opened this issue Jan 26, 2008 · 22 comments
Open

Meta ticket: Finish bipartite graph implementation #1941

rlmill mannequin opened this issue Jan 26, 2008 · 22 comments

Comments

@rlmill
Copy link
Mannequin

rlmill mannequin commented Jan 26, 2008

Systematically go through the functions of graph and generic_graph and see which ones, such as add_vertex, need to be overridden in the bipartite graph class so that everything makes sense. Right now, you can add an edge so that the bipartite graph is no longer bipartite.

  1. add to __cmp__ to distinguish Bipartite from other graphs
  2. loops - this should always be false for bipartite, right? (other functions with "loops" in the name)
  3. density - should this reflect "bipartite density"?
  4. clear - left & right too?
  5. add left_vertices and right_vertices?
  6. adjacency_matrix - should this order the vertices a certain way?
  7. add_cycle
  8. add_path
  9. add a function "bipartite_subgraph" to preserve class?
  10. bipartite_color, bipartite_sets, is_bipartite

See discussion https://groups.google.com/g/sage-devel/c/yU6nu89M4jU

Open tickets

Fixed issues

Considered invalid or duplicate

CC: @sagetrac-brunellus @maxale @tscrim

Component: graph theory

Issue created by migration from https://trac.sagemath.org/ticket/1941

@rlmill rlmill mannequin added c: graph theory labels Jan 26, 2008
@rlmill rlmill mannequin self-assigned this Jan 26, 2008
@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-2.10.2 milestone Jan 27, 2008
@rlmill
Copy link
Mannequin Author

rlmill mannequin commented Jan 27, 2008

comment:2
 1. add to __cmp__ to distinguish Bipartite from other graphs
 2. loops - this should always be false for bipartite, right? (other functions with "loops" in the name)
 3. density - should this reflect "bipartite density"?
 4. add_vertex - to which side?
 5. add_vertices - what to do with this?
 6. clear - left & right too?
 7. add left_vertices and right_vertices?
 8. complement?
 9. copy
10. add_edge(s)
11. adjacency_matrix - should this order the vertices a certain way?
12. add_cycle
13. add_path
14. add a function "bipartite_subgraph" to preserve class?
15. bipartite_color, bipartite_sets, is_bipartite

@rlmill
Copy link
Mannequin Author

rlmill mannequin commented Mar 19, 2008

comment:3

Also, the automorphism group/canonical label functions need to be called with the correct partitions.

@rlmill
Copy link
Mannequin Author

rlmill mannequin commented Feb 23, 2010

comment:4

see #8329

@rlmill
Copy link
Mannequin Author

rlmill mannequin commented Feb 23, 2010

comment:5

see also #8330

@rlmill
Copy link
Mannequin Author

rlmill mannequin commented Feb 23, 2010

comment:6

#8331 is also relevant.

@rhinton
Copy link
Mannequin

rhinton mannequin commented Feb 24, 2010

comment:7

And another #8350.

@rhinton
Copy link
Mannequin

rhinton mannequin commented Mar 4, 2010

comment:8

Also #8425.

@sagetrac-brunellus

This comment has been minimized.

@sagetrac-brunellus

This comment has been minimized.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@dcoudert
Copy link
Contributor

comment:15

Gathering tickets related to BipartiteGraph, open and fixed issues.

@dcoudert

This comment has been minimized.

@dcoudert dcoudert removed the t: bug label Jan 31, 2022
@dcoudert dcoudert changed the title Finish bipartite graph implementation Meta ticket: Finish bipartite graph implementation Jan 31, 2022
@dcoudert dcoudert modified the milestones: sage-6.4, sage-9.6 Jan 31, 2022
@maxale

This comment has been minimized.

@dcoudert

This comment has been minimized.

@slel

This comment has been minimized.

@dcoudert
Copy link
Contributor

dcoudert commented Feb 2, 2022

comment:19

Proposal from #33261#comment:3

Side note: The complete bipartite graph constructor should return a BipartiteGraph object IMO (instead of just a usual Graph).

I tried (for complete, random and random regular bipartite graphs) and it's not an easy task:

  • the __repr__ method of BipartiteGraph modifies the name string and so we have to correct several doctests
  • algorithms modifying a graph with the addition of vertices fail since the side is not given. We must either implement specific versions for BipartiteGraph or modify these algorithms to work properly with BipartiteGraph.
    So it's not so easy to do

@tscrim
Copy link
Collaborator

tscrim commented Feb 3, 2022

comment:20

Replying to @dcoudert:

Proposal from #33261#comment:3

Side note: The complete bipartite graph constructor should return a BipartiteGraph object IMO (instead of just a usual Graph).

I tried (for complete, random and random regular bipartite graphs) and it's not an easy task:

Thank you for attempting it.

  • the __repr__ method of BipartiteGraph modifies the name string and so we have to correct several doctests

This is minor IMO (although it might be good for the two to be consistent); just annoying to do.

  • algorithms modifying a graph with the addition of vertices fail since the side is not given. We must either implement specific versions for BipartiteGraph or modify these algorithms to work properly with BipartiteGraph.

This suggests that there is a compatibility issue between the two classes, which is a bug IMO since BipartiteGraph is a subclass of Graph. We probably need to modify add_vertex and add_edge to be compatible, such as returning a generic graph. Mainly, I am not sure I agree with the behavior of raising an error when the edge does not give a bipartite graph like in #8744 (although without such a complicated thing of recoloring the bipartite graph).

Essentially, IMO subclasses should behave like the base class but with extra features that utilize the special aspects (sometimes known as the "is-a" test).

@dcoudert
Copy link
Contributor

dcoudert commented Feb 3, 2022

comment:21

BipartiteGraph adds restrictions to Graph and the price to pay is to maintain the partition. When using a BipartiteGraph, some operations may be forbidden (edge contraction, etc.) or done with care (add_vertex, add_path, etc.). Otherwise, the user has to move back to Graph.

@tscrim
Copy link
Collaborator

tscrim commented Feb 4, 2022

comment:22

Then it should not be a subclass IMO because of a fundamental incompatibility with some common ABC between BipartiteGraph and Graph to explicitly prohibit said methods.

@maxale

This comment has been minimized.

@dcoudert

This comment has been minimized.

@dcoudert

This comment has been minimized.

@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 2, 2022
@enjeck

This comment has been minimized.

@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants