-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Cycle basis calculations #1957
Cycle basis calculations #1957
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1957 +/- ##
===========================================
+ Coverage 75.78% 76.11% +0.32%
===========================================
Files 350 352 +2
Lines 57486 57749 +263
===========================================
+ Hits 43567 43956 +389
+ Misses 13919 13793 -126
Continue to review full report at Codecov.
|
30db2f1
to
fbbce79
Compare
and use it for cycle basis calculations
d710e9f
to
4f4764c
Compare
Please DO NOT MERGE, just give feedback. I will merge myself later. At first, I expect technical comments, as understanding the algorithm would take time. I discussed the algorithm with @vtraag last year, but I am not sure if he remembers. |
Where feedback might be useful is an efficient algorithm to put edges in cycle order. Currently, the How the algorithm works is that it produces BFS-based fundamental cycles starting from all vertices (of degree d >= 3). This produces a list of candidate cycles of length |
Yet another thing where I need feedback is a refactoring for We probably want a begin/end style solution for |
…get rid of the inclist_t typedef
Added a begin/end style solution as the first iteration. I think it's good enough. Another alternative would have been to move the function body to a separate function and just wrap a call to that function within |
catch (const std::bad_alloc &e) { IGRAPH_ERROR(e.what(), IGRAPH_ENOMEM); /* LCOV_EXCL_LINE */ } \ | ||
catch (const std::exception &e) { IGRAPH_ERROR(e.what(), IGRAPH_FAILURE); } \ | ||
catch (...) { IGRAPH_ERROR("Unknown exception caught.", IGRAPH_FAILURE); } | ||
|
||
#define IGRAPH_HANDLE_EXCEPTIONS(code) \ | ||
IGRAPH_HANDLE_EXCEPTIONS_BEGIN; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ;
is a bit strange here as it expands to try {;
.
This is in fact why I was reluctant to do this. Maybe we can use the following pattern?
IGRAPH_HANDLE_EXCEPTIONS_BEGIN {
} IGRAPH_HANDLE_EXCEPTIONS_END;
??
A bit like
do {
} while (cond);
Not sure what's best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to remove the ;
, it has no effect. I just wanted to test that one is allowed to use IGRAPH_HANDLE_EXCEPTIONS_BEGIN
or _END
with or without a semicolon at the end without breaking thigs.
Do you mean that the input of the algorithm is a graph and a list of edge IDs in arbitrary order that are guaranteed to form a cycle, and the result should be a list where the edge IDs are in the order they are traversed along the cycle? I don't see any particular problem with the current implementation. |
Let me clarify. Here's an example of a graph with edges labelled by ID: 3, 4, 8, 5 form a cycle, in this order. However, the (internal) computation returns the edge ID in sorted order, 3, 4, 5, 8. I use a separate function, I found this a bit ugly. |
cdb3b24
to
6508af9
Compare
Continuing from #1786
This PR implements some cycle basis calculations.
It has a special feature where it can limit the length of cycles found, which drastically reduces computation time. This will be a unique feature of igraph.
Within the minimum cycle basis computation, I represent cycles as sorted vectors of edge IDs. This makes certain operations, such as "adding" cycles, efficient. However, in the end we obtain the cycles with an edge ID ordering that does not match the cycle structure. Therefore, in a final step we order the cycles. This operation was much easier with a map data structure, so I did it in C++. I could do it in pure C without writing a map from scratch, but it would be much more complicated, and I don't have the time now. There is an option that controls whether this reordering should be done. Setting it to
false
will speed the function up, though I did not yet time to benchmark by how much.This PR also adds a
igraph_vector_list_remove_consecutive_duplicates
function.