-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ladder graph generators and test_ladder
- Loading branch information
1 parent
ced0310
commit 15be344
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Licensed under the Apache License, | ||
|
||
import unittest | ||
|
||
import rustworkx | ||
|
||
|
||
class TestLadderGraph(unittest.TestCase): | ||
def test_ladder_graph(self): | ||
graph = rustworkx.generators.ladder_graph(20) | ||
self.assertEqual(len(graph), 40) | ||
self.assertEqual(len(graph.edges()), 58) | ||
|
||
def test_ladder_graph_weights(self): | ||
graph = rustworkx.generators.ladder_graph(weights=list(range(40))) | ||
self.assertEqual(len(graph), 40) | ||
self.assertEqual([x for x in range(40)], graph.nodes()) | ||
self.assertEqual(len(graph.edges()), 58) | ||
|
||
def test_ladder_no_weights_or_num(self): | ||
with self.assertRaises(IndexError): | ||
rustworkx.generators.ladder_graph() | ||
|
||
def test_zero_length_ladder_graph(self): | ||
graph = rustworkx.generators.ladder_graph(0) | ||
self.assertEqual(0, len(graph)) |