Skip to content

Commit c27b9d9

Browse files
github-actionsgithub-actions
github-actions
authored and
github-actions
committed
fixup! Format Python code with psf/black push
1 parent 35ced67 commit c27b9d9

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

Diff for: graphs/karger.py

+20-15
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
import random
66
from typing import Dict, List, Set, Tuple
77

8-
98
# Adjacency list representation of this graph:
109
# https://en.wikipedia.org/wiki/File:Single_run_of_Karger%E2%80%99s_Mincut_algorithm.svg
1110
TEST_GRAPH = {
12-
'1': ['2', '3', '4', '5'],
13-
'2': ['1', '3', '4', '5'],
14-
'3': ['1', '2', '4', '5', '10'],
15-
'4': ['1', '2', '3', '5', '6'],
16-
'5': ['1', '2', '3', '4', '7'],
17-
'6': ['7', '8', '9', '10', '4'],
18-
'7': ['6', '8', '9', '10', '5'],
19-
'8': ['6', '7', '9', '10'],
20-
'9': ['6', '7', '8', '10'],
21-
'10': ['6', '7', '8', '9', '3']
11+
"1": ["2", "3", "4", "5"],
12+
"2": ["1", "3", "4", "5"],
13+
"3": ["1", "2", "4", "5", "10"],
14+
"4": ["1", "2", "3", "5", "6"],
15+
"5": ["1", "2", "3", "4", "7"],
16+
"6": ["7", "8", "9", "10", "4"],
17+
"7": ["6", "8", "9", "10", "5"],
18+
"8": ["6", "7", "9", "10"],
19+
"9": ["6", "7", "8", "10"],
20+
"10": ["6", "7", "8", "9", "3"],
2221
}
2322

2423

@@ -61,8 +60,10 @@ def partition_graph(graph: Dict[str, List[str]]) -> Set[Tuple[str, str]]:
6160
for neighbor in uv_neighbors:
6261
graph_copy[neighbor].append(uv)
6362

64-
contracted_nodes[uv] = {contracted_node for contracted_node in
65-
contracted_nodes[u].union(contracted_nodes[v])}
63+
contracted_nodes[uv] = {
64+
contracted_node
65+
for contracted_node in contracted_nodes[u].union(contracted_nodes[v])
66+
}
6667

6768
# Remove nodes u and v.
6869
del graph_copy[u]
@@ -75,8 +76,12 @@ def partition_graph(graph: Dict[str, List[str]]) -> Set[Tuple[str, str]]:
7576

7677
# Find cutset.
7778
groups = [contracted_nodes[node] for node in graph_copy]
78-
return {(node, neighbor) for node in groups[0]
79-
for neighbor in graph[node] if neighbor in groups[1]}
79+
return {
80+
(node, neighbor)
81+
for node in groups[0]
82+
for neighbor in graph[node]
83+
if neighbor in groups[1]
84+
}
8085

8186

8287
if __name__ == "__main__":

Diff for: web_programming/world_covid19_stats.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python3
22

3-
'''
3+
"""
44
Provide the current worldwide COVID-19 statistics.
55
This data is being scrapped from 'https://www.worldometers.info/coronavirus/'.
6-
'''
6+
"""
77

88
import requests
99
from bs4 import BeautifulSoup
@@ -13,8 +13,8 @@ def world_covid19_stats(url: str = "https://www.worldometers.info/coronavirus")
1313
"""
1414
Return a dict of current worldwide COVID-19 statistics
1515
"""
16-
soup = BeautifulSoup(requests.get(url).text, 'html.parser')
17-
keys = soup.findAll('h1')
16+
soup = BeautifulSoup(requests.get(url).text, "html.parser")
17+
keys = soup.findAll("h1")
1818
values = soup.findAll("div", {"class": "maincounter-number"})
1919
keys += soup.findAll("span", {"class": "panel-title"})
2020
values += soup.findAll("div", {"class": "number-table-main"})

0 commit comments

Comments
 (0)