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

Direct betweenness #2352

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

Conversation

GroteGnoom
Copy link
Member

@GroteGnoom GroteGnoom commented May 28, 2023

Fixes #1796

Making cutoffs work seems like a lot of work, because the only shortest path functions with cutoffs are igraph_distances_cutoff, igraph_distances_dijkstra_cutoff, which don't actually give me the paths.

subset betweenness should be doable.
Edit:
subset betweenness is way harder than I thought.

the FINALLY stack is a mess, that still needs to be fixed.

@codecov
Copy link

codecov bot commented May 28, 2023

Codecov Report

Merging #2352 (15c8ae8) into master (6e3d61b) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2352   +/-   ##
=======================================
  Coverage   83.46%   83.46%           
=======================================
  Files         376      376           
  Lines       61576    61576           
=======================================
+ Hits        51394    51397    +3     
+ Misses      10182    10179    -3     
Impacted Files Coverage Δ
src/paths/all_shortest_paths.c 98.16% <ø> (+0.91%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e3d61b...15c8ae8. Read the comment docs.

@GroteGnoom
Copy link
Member Author

GroteGnoom commented Jun 3, 2023

If I have an undirected line:

igraph_small(&graph, 5, IGRAPH_UNDIRECTED, 0,1, 1,2, -1);

and I do a subset betweenness between source 0, and target 2:

igraph_vss_range(0, 1), igraph_vss_range(2,3))

Then for vertex 1 I should get a betweenness of 1, right? Not 0.5.

The original implementation just divides the end result by 2 for undirected situations, but I think that's incorrect. That only works if your targets and sources are the same. If there's no overlap then there is no division needed at all, and if there is a little overlap, you can't use a basic division at the end to fix everything.

@szhorvat
Copy link
Member

szhorvat commented Jun 3, 2023

Making cutoffs work seems like a lot of work, because the only shortest path functions with cutoffs are igraph_distances_cutoff, igraph_distances_dijkstra_cutoff, which don't actually give me the paths.

Let's skip this until the necessary functions are implemented. #2358

@szhorvat
Copy link
Member

szhorvat commented Jun 3, 2023

If I have an undirected line:

igraph_small(&graph, 5, IGRAPH_UNDIRECTED, 0,1, 1,2, -1);

and I do a subset betweenness between source 0, and target 2:

igraph_vss_range(0, 1), igraph_vss_range(2,3))

Then for vertex 1 I should get a betweenness of 1, right? Not 0.5.

Correct.

The original implementation just divides the end result by 2 for undirected situations, but I think that's incorrect. That only works if your targets and sources are the same. If there's no overlap then there is no division needed at all, and if there is a little overlap, you can't use a basic division at the end to fix everything.

I believe you are right. I'd have to look into this in more detail to see how the subset version works and how it can be fixed most effectively.

But we are making progress, we discovered a bug, so that's good. This was precisely the purpose of the direct implementation.

@szhorvat
Copy link
Member

szhorvat commented Jun 3, 2023

@ntamas
Copy link
Member

ntamas commented Jun 4, 2023

I believe you are right.

Yes, you are correct. This seems to be a bug indeed. Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a direct implementation of betweenness for testing
3 participants