Skip to content

Commit

Permalink
fixup! Format Python code with psf/black push
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and github-actions committed Aug 4, 2020
1 parent fe5ed92 commit 66372e5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
35 changes: 20 additions & 15 deletions graphs/karger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
import random
from typing import Dict, List, Set, Tuple


# Adjacency list representation of this graph:
# https://en.wikipedia.org/wiki/File:Single_run_of_Karger%E2%80%99s_Mincut_algorithm.svg
TEST_GRAPH = {
'1': ['2', '3', '4', '5'],
'2': ['1', '3', '4', '5'],
'3': ['1', '2', '4', '5', '10'],
'4': ['1', '2', '3', '5', '6'],
'5': ['1', '2', '3', '4', '7'],
'6': ['7', '8', '9', '10', '4'],
'7': ['6', '8', '9', '10', '5'],
'8': ['6', '7', '9', '10'],
'9': ['6', '7', '8', '10'],
'10': ['6', '7', '8', '9', '3']
"1": ["2", "3", "4", "5"],
"2": ["1", "3", "4", "5"],
"3": ["1", "2", "4", "5", "10"],
"4": ["1", "2", "3", "5", "6"],
"5": ["1", "2", "3", "4", "7"],
"6": ["7", "8", "9", "10", "4"],
"7": ["6", "8", "9", "10", "5"],
"8": ["6", "7", "9", "10"],
"9": ["6", "7", "8", "10"],
"10": ["6", "7", "8", "9", "3"],
}


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

contracted_nodes[uv] = {contracted_node for contracted_node in
contracted_nodes[u].union(contracted_nodes[v])}
contracted_nodes[uv] = {
contracted_node
for contracted_node in contracted_nodes[u].union(contracted_nodes[v])
}

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

# Find cutset.
groups = [contracted_nodes[node] for node in graph_copy]
return {(node, neighbor) for node in groups[0]
for neighbor in graph[node] if neighbor in groups[1]}
return {
(node, neighbor)
for node in groups[0]
for neighbor in graph[node]
if neighbor in groups[1]
}


if __name__ == "__main__":
Expand Down
8 changes: 4 additions & 4 deletions web_programming/world_covid19_stats.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3

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

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

0 comments on commit 66372e5

Please sign in to comment.