Add isLinear and isChordless methods to GraphTests#1286
Open
Wissal-Chbani wants to merge 4 commits into
jgrapht:masterjgrapht/jgrapht:masterfrom
Wissal-Chbani:feature/isLinear-isChordlessWissal-Chbani/jgrapht:feature/isLinear-isChordlessCopy head branch name to clipboard
Open
Add isLinear and isChordless methods to GraphTests#1286Wissal-Chbani wants to merge 4 commits intojgrapht:masterjgrapht/jgrapht:masterfrom Wissal-Chbani:feature/isLinear-isChordlessWissal-Chbani/jgrapht:feature/isLinear-isChordlessCopy head branch name to clipboard
Wissal-Chbani wants to merge 4 commits into
jgrapht:masterjgrapht/jgrapht:masterfrom
Wissal-Chbani:feature/isLinear-isChordlessWissal-Chbani/jgrapht:feature/isLinear-isChordlessCopy head branch name to clipboard
Conversation
Member
|
A couple of trivial checkstyle failures need to be fixed. |
jsichi
requested changes
Jan 10, 2026
|
|
||
| /** | ||
| * Test whether a graph is linear (path graph). | ||
| * A graph is linear if: |
Member
There was a problem hiding this comment.
Use proper Javadoc format for numbered lists (otherwise this will come out unreadable in the generated Javadoc).
| /** | ||
| * Test whether a graph is linear (path graph). | ||
| * A graph is linear if: | ||
| * 1. It is undirected. |
Member
There was a problem hiding this comment.
Why does the graph have to be undirected? A linear directed graph is a well-defined concept.
| * Test whether a cycle is chordless (induced). | ||
| * | ||
| * <p> | ||
| * A cycle is chordless if there are no edges between non-consecutive |
Member
There was a problem hiding this comment.
For long cycles, isn't there a more efficient algorithm?
| * Test whether a graph is empty. An empty graph on n nodes consists of n isolated vertices with | ||
| * no edges. | ||
| * | ||
| * |
Member
There was a problem hiding this comment.
Please don't modify unrelated code; it causes spurious merge conflicts. Set your editor to only reformat code that you are actually changing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses #1235.
This PR adds two new utility methods to the
GraphTestsclass for testing graph properties:Changes Made
isLinear(Graph<V, E> graph)isChordless(Graph<V, E> graph, GraphPath<V, E> cycle)Why These Methods?
These methods provide useful graph property testing functionality that was previously missing from the library. Linear graphs and chordless cycles are fundamental concepts in graph theory with applications in network analysis, structural analysis, and algorithm design.
Testing
Comprehensive unit tests have been added in
GraphTestsTest:Documentation
HISTORY.mdorCONTRIBUTORS.md