-
Notifications
You must be signed in to change notification settings - Fork 103
Add Bernoulli random graph #200
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
Open
aurorarossi
wants to merge
50
commits into
JuliaGraphs:master
Choose a base branch
from
aurorarossi:bernoulli_random_graphs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
061f7a7
Fix randbn
aurorarossi cad14af
Add tests randbn
aurorarossi c9fe434
Add comment
aurorarossi 3876f6e
Use statistics
aurorarossi a023ad9
Add std from Statistics for test
aurorarossi 48f12c4
Add bernoulli graph
aurorarossi 1c7bd09
Add correlated bernoulli graphs
aurorarossi b8eb7f6
Add tests
aurorarossi ec62227
Export new functions
aurorarossi 923a665
Remove bracket
aurorarossi a850907
Merge branch 'master' into bernoulli_random_graphs
aurorarossi e57b04a
Remove merged double test
aurorarossi fd249a9
Add test for non-isomorphism case
aurorarossi 40c3dfa
Remove test
aurorarossi ed768f7
Fix typo
aurorarossi 795df03
Add assert size
aurorarossi 1ad8c10
Fix docstrings
aurorarossi 13ddd4a
Add more tests
aurorarossi dab77a6
Fix seed and rng bernoulli
aurorarossi 283a335
Add parenthesis, remove cor
aurorarossi 7d5f907
Remove double space
aurorarossi 6cec8cc
Add space
aurorarossi 7275adb
Remove brackets in ignore formatter
aurorarossi 7eb11dd
Merge branch 'bernoulli_random_graphs' of https://github.com/auroraro…
aurorarossi 7e8599b
Change Lambda type in Abstract Matrix
aurorarossi 07ae8e7
Remove seed in bernoulli graph
aurorarossi 559e49f
Remove seed in test bernoulli graph
aurorarossi 855eb79
Remove comment
aurorarossi 2a84eac
Remove seed in rho correlated
aurorarossi 7e66910
Remove rng function
aurorarossi 0a1f121
Change in sparse matrix rho correlated
aurorarossi 22ed227
Remove seed test
aurorarossi 7146795
Remove assert
aurorarossi 758e95f
Add check Lambda symmetric
aurorarossi e958ffd
Add test_throws bernoulli graphs
aurorarossi 0323cbd
Change name variables and formatting
aurorarossi 806f93d
Simplify lines
aurorarossi 0043a16
Remove `Int.`
aurorarossi fa9e5c7
Add rng in docstrings
aurorarossi 04ed8a2
Add tuple info in docstring
aurorarossi b5025e3
Remove heavy latex
aurorarossi 6b04036
Add explanation in docstring
aurorarossi 2746f6f
Add error rho interval
aurorarossi f072757
Add test rho exception
aurorarossi b9ca077
Format
aurorarossi 64fc9ec
Add eltype specification
aurorarossi 698eb46
Rename function
aurorarossi 39627f6
Rename function and remove latex docstrings
aurorarossi aea0909
Merge branch 'my_master' into bernoulli_random_graphs
aurorarossi 1d326cb
Merge branch 'my_master' into bernoulli_random_graphs
aurorarossi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -423,4 +423,33 @@ | |
@test μ1 - sv1 <= 0.3 * 5 <= μ1 + sv1 # since the stdev of μ1 is around sv1/sqrt(N), this should rarely fail | ||
@test μ2 - sv2 <= 0.7 * 3 <= μ2 + sv2 | ||
end | ||
|
||
@testset "bernoulli graphs" begin | ||
n = 50 | ||
Λ = sparse(rand(n, n)) | ||
@test_throws ArgumentError("Λ must be symmetric") bernoulli_graph(Λ; rng) | ||
@test_throws ArgumentError("The probability matrix must be a square matrix") bernoulli_graph( | ||
sparse(rand(2, 3)); rng | ||
) | ||
Λ = Symmetric(Λ) | ||
@test_throws ArgumentError("ρ must be in [0,1]") correlated_bernoulli_graphs( | ||
Λ, -1.0; rng | ||
) | ||
ρ = 1.0 # isomorphism case | ||
aurorarossi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
g1, g2 = correlated_bernoulli_graphs(Λ, ρ; rng) | ||
g1_adj = adjacency_matrix(g1) | ||
g2_adj = adjacency_matrix(g2) | ||
@test g1_adj == g2_adj | ||
@test diag(g1_adj) == diag(g2_adj) == zeros(n) | ||
ρ = 0.5 # non isomorphism case | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we do a probabilistic test on the correlation with ample error margins? |
||
g3, g4 = correlated_bernoulli_graphs(Λ, ρ; rng) | ||
g3_adj = adjacency_matrix(g3) | ||
g4_adj = adjacency_matrix(g4) | ||
@test g3_adj != g4_adj | ||
@test diag(g3_adj) == diag(g4_adj) == zeros(n) | ||
g5 = bernoulli_graph(Λ; rng) | ||
for g in testgraphs(g5) | ||
@test nv(g) == n | ||
end | ||
end | ||
end |
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.
Uh oh!
There was an error while loading. Please reload this page.