You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -409,7 +403,7 @@ function isdigraphical(indegree_sequence::Vector{<:Integer}, outdegree_sequence:
409
403
# Similarly for `outdegree_min_sum`.
410
404
411
405
@inboundsfor r =1:(n -1)
412
-
406
+
413
407
indegree_sum += sorted_indegree_sequence[r]
414
408
outdegree_min_sum =sum([min(sorted_outdegree_sequence[i], r-1) for i in1:r])
415
409
cum_min =sum([min(sorted_outdegree_sequence[i], r) for i in (1+r):n])
@@ -422,9 +416,8 @@ function isdigraphical(indegree_sequence::Vector{<:Integer}, outdegree_sequence:
422
416
returntrue
423
417
end
424
418
425
-
426
419
"""
427
-
_random_undirected_configuration(empty_mg::M, degree_sequence::Vector{ <: Integer}) where {T,U,M <: MultilayerGraph{T,U}}
420
+
_random_undirected_configuration(empty_mg::M, degree_sequence::Vector{ <: Integer}) where {T,U,M <: MultilayerGraph{T,U}}
428
421
429
422
Internal function. Returns a `MultilayerEdge` list compatible with `empty_mg`, using a relatively inefficient algorithm.
430
423
"""
@@ -448,8 +441,8 @@ function _random_undirected_configuration(empty_mg::M, degree_sequence::Vector{
448
441
try
449
442
dsts =nothing
450
443
if allow_self_loops
451
-
dsts =sample(collect(keys(mvs_degree_dict)), mvs_degree_dict[src]; replace =false) # This would be correct but we have no "isgraphical" function that takes into account self loops. This section of the code is thus disabled.
452
-
else
444
+
dsts =sample(collect(keys(mvs_degree_dict)), mvs_degree_dict[src]; replace =false) # This would be correct but we have no "isgraphical" function that takes into account self loops. This section of the code is thus disabled.
@@ -476,7 +469,7 @@ function _random_undirected_configuration(empty_mg::M, degree_sequence::Vector{
476
469
end
477
470
else
478
471
continue
479
-
end
472
+
end
480
473
end
481
474
success =length(mvs_degree_dict) ==0
482
475
end
@@ -502,34 +495,34 @@ function _random_directed_configuration(empty_mg::M, indegree_sequence::Vector{
502
495
@info"Looping through wirings to find one that works..."
503
496
# Loop until a successful wiring is found
504
497
while!success
505
-
498
+
506
499
mvs_indegree_dict =Dict(mv => indeg for (mv,indeg) inzip(mvs,indegree_sequence) if indeg !=0)
507
500
mvs_outdegree_dict =Dict(mv => outdeg for (mv,outdeg) inzip(mvs,outdegree_sequence) if outdeg !=0)
508
501
edge_list = MultilayerEdge[]
509
502
for src in mvs
510
-
503
+
511
504
if src inkeys(mvs_outdegree_dict)
512
505
try
513
506
dsts =nothing
514
507
if allow_self_loops
515
-
dsts =sample(collect(keys(mvs_indegree_dict)), mvs_outdegree_dict[src]; replace =false) # This would be correct but we have no "isgraphical" function that takes into account self loops. This section of the code is thus disabled.
516
-
else
508
+
dsts =sample(collect(keys(mvs_indegree_dict)), mvs_outdegree_dict[src]; replace =false) # This would be correct but we have no "isgraphical" function that takes into account self loops. This section of the code is thus disabled.
cartIndexTovecIndex(cart_index::CartesianIndex, tensor_size::NTuple{N, <: Integer} ) where N
545
+
cartIndexTovecIndex(cart_index::CartesianIndex, tensor_size::NTuple{N, <: Integer} ) where N
556
546
557
547
Internal function. Converts `cart_index` to an integer index such that it corresponds to the same element under flattening of the tensor whose size is `tensor_size`.
@@ -574,15 +564,15 @@ Returns a simple graph with a given finite degree sequence of non-negative integ
574
564
functionhavel_hakimi_(empty_graph::SimpleGraph, degree_sequence::Vector{<:Integer}) # Please think about a decent name!
575
565
# Check whether the given degree sequence contains only non-negative integers
576
566
!any(degree -> degree <0, degree_sequence) ||throw(ArgumentError("The degree sequence (degree_sequence) is invalid: it must contain non-negative integers only."))
577
-
# Check whether the given degree sequence is compatible with the given multilayer graph
578
-
nv(empty_graph) ==length(degree_sequence) ||throw(ArgumentError("The degree sequence (degree_sequence) and the multilayer graph (empty_mg) are incompatible: the length of the degree sequence doesn't coincide with the number of vertices."))
579
-
# Check whether the given degree sequence is graphical
580
-
isgraphical(degree_sequence) ||throw(ArgumentError("The degree sequence (degree_sequence) is invalid: it must be graphical (i.e. realizable in a simple graph)."))
581
-
# Check whether the given multilayer graph is undirected
567
+
# Check whether the given degree sequence is compatible with the given multilayer graph
568
+
nv(empty_graph) ==length(degree_sequence) ||throw(ArgumentError("The degree sequence (degree_sequence) and the multilayer graph (empty_mg) are incompatible: the length of the degree sequence doesn't coincide with the number of vertices."))
569
+
# Check whether the given degree sequence is graphical
570
+
isgraphical(degree_sequence) ||throw(ArgumentError("The degree sequence (degree_sequence) is invalid: it must be graphical (i.e. realizable in a simple graph)."))
571
+
# Check whether the given multilayer graph is undirected
582
572
!is_directed(empty_mg) ||throw(ArgumentError("The multilayer graph (empty_mg) is invalid: it must be undirected."))
583
-
# Get all the multilayer vertices from the empty multilayer graph
573
+
# Get all the multilayer vertices from the empty multilayer graph
584
574
##mvs = mv_vertices(empty_mg)
585
575
# Get the length of the degree sequence
586
576
##n = length(degree_sequence)
587
577
##mvs_degree_dict = Dict(mv => deg for (mv, deg) in zip(mvs, degree_sequence) if deg > 0)
0 commit comments