Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Assortativity extended to graphs with attributes #1547

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

vboussange
Copy link

@vboussange vboussange commented Mar 8, 2021

Hi there, I propose an extension of method assortativity to account for scalar properties of vertices.
This is also done in networkX (python).

"""
assortativity(g,labels)
Similar to assortativity(g) except that Pearson correlation is calculated between some values associated to each node and stored in
labels.

Arguments

  • labels is a dictionary that associates to each vertex index a scalar value

Examples

julia> using LightGraphs

julia> labels = Dict(collect(1:4) .=> [-1., -1., 1., 1.])

julia> assortativity(star_graph(4),labels)
-0.5

"""

@vboussange vboussange changed the title Assortativity extended Assortativity extended to graphs with attributes Mar 8, 2021
@codecov
Copy link

codecov bot commented Mar 8, 2021

Codecov Report

Merging #1547 (cd7a842) into master (5d2b80a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head cd7a842 differs from pull request most recent head 91a3f08. Consider uploading reports for the commit 91a3f08 to get more accurate results

@@           Coverage Diff           @@
##           master    #1547   +/-   ##
=======================================
  Coverage   99.44%   99.44%           
=======================================
  Files         106      106           
  Lines        5551     5564   +13     
=======================================
+ Hits         5520     5533   +13     
  Misses         31       31           

@sbromberger
Copy link
Owner

Thanks for these PRs, @vboussange ! In order for us to merge them, they will need comprehensive tests.

Also, a formal review is forthcoming, but why are you using a Dict for vertex indices instead of a Vector{T}? Vectors are much more efficient.

@vboussange
Copy link
Author

Thanks for these PRs, @vboussange ! In order for us to merge them, they will need comprehensive tests.

Also, a formal review is forthcoming, but why are you using a Dict for vertex indices instead of a Vector{T}? Vectors are much more efficient.

@sbromberger Thanks for your comments. I was using Dict because of personal historical contingencies. You are right - Vector makes much more sense. I have made a new commit with the updated function, added some tests, and modified the documentation accordingly.

@sbromberger
Copy link
Owner

sorry for the delay in review - I should be able to get to this this week.

src/community/assortativity.jl Outdated Show resolved Hide resolved
src/community/assortativity.jl Outdated Show resolved Hide resolved
src/community/assortativity.jl Show resolved Hide resolved
test/community/assortativity.jl Outdated Show resolved Hide resolved
test/community/assortativity.jl Outdated Show resolved Hide resolved
@sbromberger
Copy link
Owner

Best of intentions, etc. Sorry for the delay. Reviewing now.

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

Successfully merging this pull request may close these issues.

None yet

2 participants