Skip to content

Commit 0730fe9

Browse files
committed
chore(lint): fix linting issues
1 parent b04dc64 commit 0730fe9

File tree

9 files changed

+65
-27
lines changed

9 files changed

+65
-27
lines changed

datastructures/graphs/edge/edge.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
T = TypeVar("T")
88

9+
910
class Edge(ABC, Generic[T]):
1011
"""
1112
Edge representation of an abstract Edge in a Graph

datastructures/graphs/edge/edge_directed.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@
55

66
T = TypeVar("T")
77

8+
89
class DirectedEdge(Edge, Generic[T]):
910
"""
1011
Directed Edge representation of a directed Edge in a Graph where the edge connects two vertices which has a source
1112
vertex and a destination vertex.
1213
"""
1314

14-
def __init__(self, source: Any, destination: Any, weight: Optional[Union[int, float]] = None,
15-
properties: Optional[Dict[str, Any]] = None,
16-
identifier: AnyStr = uuid4()):
15+
def __init__(
16+
self,
17+
source: Any,
18+
destination: Any,
19+
weight: Optional[Union[int, float]] = None,
20+
properties: Optional[Dict[str, Any]] = None,
21+
identifier: AnyStr = uuid4(),
22+
):
1723
super().__init__(weight, properties, identifier)
1824
self.source = source
1925
self.destination = destination

datastructures/graphs/edge/edge_hyper.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55

66
T = TypeVar("T")
77

8+
89
class HyperEdge(Edge, Generic[T]):
910
"""
1011
HyperEdge representation of a hyper-edge in a Graph where the edge connects to the multiple vertices
1112
"""
1213

13-
def __init__(self, nodes: List[Any], weight: Optional[Union[int, float]] = None,
14-
properties: Optional[Dict[str, Any]] = None,
15-
identifier: AnyStr = uuid4()):
14+
def __init__(
15+
self,
16+
nodes: List[Any],
17+
weight: Optional[Union[int, float]] = None,
18+
properties: Optional[Dict[str, Any]] = None,
19+
identifier: AnyStr = uuid4(),
20+
):
1621
super().__init__(weight, properties, identifier)
1722
self.nodes = nodes
1823

datastructures/graphs/edge/edge_self.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55

66
T = TypeVar("T")
77

8+
89
class SelfEdge(Edge, Generic[T]):
910
"""
1011
Self-Edge representation of a self-edge in a Graph where the edge connects to the same vertex
1112
"""
1213

13-
def __init__(self, node: Any, weight: Optional[Union[int, float]] = None,
14-
properties: Optional[Dict[str, Any]] = None,
15-
identifier: AnyStr = uuid4()):
14+
def __init__(
15+
self,
16+
node: Any,
17+
weight: Optional[Union[int, float]] = None,
18+
properties: Optional[Dict[str, Any]] = None,
19+
identifier: AnyStr = uuid4(),
20+
):
1621
super().__init__(weight, properties, identifier)
1722
self.node_one = node
1823

datastructures/graphs/edge/edge_undirected.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,28 @@
55

66
T = TypeVar("T")
77

8+
89
class UndirectedEdge(Edge, Generic[T]):
910
"""
1011
Undirected Edge representation of an undirected Edge in a Graph where the edge connects two vertices.
1112
"""
1213

13-
def __init__(self, node_one: Any, node_two: Any, weight: Optional[Union[int, float]] = None,
14-
properties: Optional[Dict[str, Any]] = None,
15-
identifier: AnyStr = uuid4()):
14+
def __init__(
15+
self,
16+
node_one: Any,
17+
node_two: Any,
18+
weight: Optional[Union[int, float]] = None,
19+
properties: Optional[Dict[str, Any]] = None,
20+
identifier: AnyStr = uuid4(),
21+
):
1622
super().__init__(weight, properties, identifier)
1723
self.node_one = node_one
1824
self.node_two = node_two
1925

2026
def __str__(self):
21-
return f"{super().__str__()}, NodeOne: {self.node_one}, NodeTwo: {self.node_two}"
27+
return (
28+
f"{super().__str__()}, NodeOne: {self.node_one}, NodeTwo: {self.node_two}"
29+
)
2230

2331
def edge_type(self) -> EdgeType:
2432
return EdgeType.Undirected

datastructures/graphs/test_vertex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ def test_1(self):
1212
self.assertEqual(True, False) # add assertion here
1313

1414

15-
if __name__ == '__main__':
15+
if __name__ == "__main__":
1616
unittest.main()

datastructures/graphs/undirected/test_utils.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,32 @@
66

77
class ClosestNodeToPathInTreeTestCase(unittest.TestCase):
88

9-
@parameterized.expand([
10-
(3, [[0,1],[1,2]], [[0,2,1]], [1]),
11-
(4, [[0,1],[1,2],[1,3]], [[2,3,0]], [1]),
12-
(6, [[0,1],[0,2],[0,3],[0,4],[0,5]], [[1,5,2],[2,3,4]], [0,0]),
13-
(7, [[0,1],[0,2],[0,3],[1,4],[2,5],[2,6]], [[5,3,4],[5,3,6]], [0,2]),
14-
(3, [[0,1],[1,2]], [[0,1,2]], [1]),
15-
(3, [[0,1],[1,2]], [[0,0,0]], [0]),
16-
])
17-
def test_closest_node(self, n: int, edges: List[List[int]], query: List[List[int]], expected: int):
9+
@parameterized.expand(
10+
[
11+
(3, [[0, 1], [1, 2]], [[0, 2, 1]], [1]),
12+
(4, [[0, 1], [1, 2], [1, 3]], [[2, 3, 0]], [1]),
13+
(
14+
6,
15+
[[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]],
16+
[[1, 5, 2], [2, 3, 4]],
17+
[0, 0],
18+
),
19+
(
20+
7,
21+
[[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [2, 6]],
22+
[[5, 3, 4], [5, 3, 6]],
23+
[0, 2],
24+
),
25+
(3, [[0, 1], [1, 2]], [[0, 1, 2]], [1]),
26+
(3, [[0, 1], [1, 2]], [[0, 0, 0]], [0]),
27+
]
28+
)
29+
def test_closest_node(
30+
self, n: int, edges: List[List[int]], query: List[List[int]], expected: int
31+
):
1832
actual = closest_node(n, edges, query)
1933
self.assertEqual(expected, actual)
2034

2135

22-
if __name__ == '__main__':
36+
if __name__ == "__main__":
2337
unittest.main()

datastructures/graphs/undirected/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def find_path(start: int, end: int) -> List[int]:
7979

8080
# Find the node on the path with minimum distance to target
8181
# If there's a tie, we want the one with the smallest index
82-
min_distance = float('inf')
82+
min_distance = float("inf")
8383
closest = -1
8484

8585
for node in found_path:

datastructures/graphs/vertex.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(
2727
self.incoming_edges = incoming_edges
2828
self.outgoing_edges = outgoing_edges
2929
self.edges = self.incoming_edges.union(self.outgoing_edges)
30-
self.adjacent_vertices: Dict[str, 'Vertex'] = {}
30+
self.adjacent_vertices: Dict[str, "Vertex"] = {}
3131
self.properties = properties
3232

3333
def __str__(self):
@@ -125,4 +125,3 @@ def out_degree(self) -> int:
125125
out_degrees += 1
126126

127127
return out_degrees
128-

0 commit comments

Comments
 (0)