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 get_adjacency_submatrix #2379

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

Conversation

GroteGnoom
Copy link
Member

Fixes #2196

@codecov
Copy link

codecov bot commented Jul 29, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.32%. Comparing base (e874c4a) to head (001b147).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2379   +/-   ##
=======================================
  Coverage   84.31%   84.32%           
=======================================
  Files         380      380           
  Lines       62217    62254   +37     
  Branches    12207    12217   +10     
=======================================
+ Hits        52461    52498   +37     
  Misses       9756     9756           
Files Coverage Δ
src/misc/conversion.c 94.33% <100.00%> (+0.51%) ⬆️

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 e874c4a...001b147. Read the comment docs.

@szhorvat
Copy link
Member

The time complexity of igraph_get_all_eids_between() should be investigated and included in the docs. It should be logarithmic due to the binary search, but logarithmic in what?

@szhorvat
Copy link
Member

Either way, I suspect this will be too slow. Technically, this function will always take time proportional to the number of matrix elements due to igraph_matrix_null(). But in practice igraph_matrix_null() is extremely fast, and won't dominate the timings. What matters is the other operations.

This particular solution does as many edge lookups as the number of matrix elements, i.e. $N_\text{from} \times N_\text{to}$.

Nevertheless, this implementation is so simple that we can have high confidence in it. Thus let's use it to expand the tests before moving on to implementing a faster one.

What I proposed in the issue using sorted intersections should take time $N_\text{from} \times \langle d \rangle_\text{from}$ where $\langle d \rangle$ denotes the mean degree. I expect that in most practical cases $N_\text{to} &gt;&gt; \langle d \rangle_\text{from}$, but this is not necessarily the case, especially for small submatrices.

So it will be useful to think about various types of applications. Will the submatrices be smaller or larger than the typical degree?

@ntamas
Copy link
Member

ntamas commented Jul 29, 2023

@szhorvat So, am I right to assume in light of your comments that you are in favour of merging this PR even if you have concerns about the performance?

@GroteGnoom is this still a draft or is it ready to be merged?

@szhorvat
Copy link
Member

szhorvat commented Jul 29, 2023

No, I think we should fix the performance.

It is not ready, loop edges are not handled. Although that would be easy with an if (from == to) in the inner loop. LOOPS_ONCE vs LOOPS_TWICE also needs to be handled.

And we need docs.

@GroteGnoom
Copy link
Member Author

GroteGnoom commented Jul 29, 2023

It is not ready, loop edges are not handled.

I think they are? (the TODO can be removed I think)

But it's still a mess, so I'll at least clean up first. And I don't mind looking at performance either.

@szhorvat
Copy link
Member

I think they are? (the TODO can be removed I think)

Sorry about that, I didn't look carefully enough.

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.

Adjacency matrix for only some vertices
3 participants