We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b55eaae commit 1aaf383Copy full SHA for 1aaf383
1 file changed
lib/Graph.rakumod
@@ -511,13 +511,22 @@ class Graph
511
%index{$vertex} = $prefix ~ $index++;
512
}
513
514
+ my %seen;
515
my %new-adjacency-list;
516
for self.edges(:dataset) -> %e {
517
%new-adjacency-list{%index{%e<from>}}{%index{%e<to>}} = %e<weight>;
518
if !self.directed {
519
%new-adjacency-list{%index{%e<to>}}{%index{%e<from>}} = %e<weight>;
520
521
+ %seen{%e<from>}++;
522
+ %seen{%e<to>}++
523
524
+
525
+ # In case there are vertices with no edges
526
+ for @vs.grep({ %seen{$_}:!exists }) -> $v {
527
+ %new-adjacency-list.push( %index{$v} => {} )
528
+ }
529
530
my $vertex-coordinates = do if self.vertex-coordinates ~~ Map:D {
531
self.vertex-coordinates.map({ %index{$_.key} => $_.value }).Hash
532
} else { Whatever }
0 commit comments