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

Add is_bipartite(::Graph) #4499

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

Sequenzer
Copy link
Collaborator

The title says it all.

@lgoettgens lgoettgens changed the title Added Function is_bipartite Add is_bipartite(::Graph) Jan 24, 2025
@lgoettgens lgoettgens added topic: combinatorics release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes labels Jan 24, 2025
@lgoettgens lgoettgens requested a review from benlorenz January 24, 2025 17:27
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.55%. Comparing base (f329ec4) to head (3055a4f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4499   +/-   ##
=======================================
  Coverage   84.55%   84.55%           
=======================================
  Files         672      672           
  Lines       88888    88890    +2     
=======================================
+ Hits        75157    75160    +3     
+ Misses      13731    13730    -1     
Files with missing lines Coverage Δ
src/Combinatorics/Graphs/functions.jl 96.74% <100.00%> (+0.03%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Member

@benlorenz benlorenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few suggestions, and please add the function to docs/src/Combinatorics/graphs.md.

Comment on lines +1356 to +1357
function is_bipartite(g::Graph{T}) where T
return Polymake.graph.Graph{T}(ADJACENCY=g.pm_graph).BIPARTITE::Bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function is_bipartite(g::Graph{T}) where T
return Polymake.graph.Graph{T}(ADJACENCY=g.pm_graph).BIPARTITE::Bool
function is_bipartite(g::Graph{Undirected})
return Polymake.graph.Graph{Undirected}(ADJACENCY=pm_object(g)).BIPARTITE::Bool

This is only defined for undirected graphs.

graph/objects/Combinatorics/Graph/properties/BIPARTITE:
property BIPARTITE : Bool
 Only defined for Graph<Undirected>.
 True if the graph is a bipartite.

# Examples
```
julia> g = graph_from_edges([1,2],[2,3],[3,4]]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
julia> g = graph_from_edges([1,2],[2,3],[3,4]]);
julia> g = graph_from_edges([[1,2],[2,3],[3,4]]);

```
julia> g = graph_from_edges([1,2],[2,3],[3,4]]);
julia> is_bipartite(G)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
julia> is_bipartite(G)
julia> is_bipartite(g)

@@ -1339,3 +1339,20 @@ function laplacian_matrix(g::Graph)
A = matrix(ZZ, adjacency_matrix(g))
return D-A
end

@doc raw"""
is_bipartite(g::Graph)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_bipartite(g::Graph)
is_bipartite(g::Graph{Undirected})

@doc raw"""
is_bipartite(g::Graph)
Returns true if the graph `g` is bipartite.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Returns true if the graph `g` is bipartite.
Returns true if the undirected graph `g` is bipartite.

Returns true if the graph `g` is bipartite.
# Examples
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```jldoctest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: combinatorics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants