Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ import re
|
|
20 |
import subprocess
|
21 |
from dataclasses import dataclass
|
22 |
from tempfile import NamedTemporaryFile
|
23 |
-
from typing import Dict, IO, List, cast, Tuple, Optional
|
24 |
|
25 |
import gradio as gr
|
26 |
import matplotlib.pyplot as plt
|
@@ -98,6 +98,7 @@ def visualize(G: nx.Graph, seed: int = 0) -> plt.Figure:
|
|
98 |
return fig
|
99 |
|
100 |
|
|
|
101 |
def watset(G: nx.Graph, algorithm: str, seed: int = 0,
|
102 |
jar: str = 'watset.jar', timeout: int = 10) -> Tuple[pd.DataFrame, Optional[nx.Graph]]:
|
103 |
with (NamedTemporaryFile() as graph,
|
@@ -156,7 +157,8 @@ def handler(file: IO[bytes], algorithm: str, seed: int) -> Tuple[pd.DataFrame, p
|
|
156 |
|
157 |
G: nx.Graph = nx.read_edgelist(file.name, delimiter=delimiter, comments='\n', data=[('weight', float)])
|
158 |
|
159 |
-
mapping,
|
|
|
160 |
|
161 |
for i, node in enumerate(G):
|
162 |
mapping[node] = i
|
|
|
20 |
import subprocess
|
21 |
from dataclasses import dataclass
|
22 |
from tempfile import NamedTemporaryFile
|
23 |
+
from typing import Dict, IO, List, cast, Tuple, Optional, Any
|
24 |
|
25 |
import gradio as gr
|
26 |
import matplotlib.pyplot as plt
|
|
|
98 |
return fig
|
99 |
|
100 |
|
101 |
+
# noinspection PyPep8Naming
|
102 |
def watset(G: nx.Graph, algorithm: str, seed: int = 0,
|
103 |
jar: str = 'watset.jar', timeout: int = 10) -> Tuple[pd.DataFrame, Optional[nx.Graph]]:
|
104 |
with (NamedTemporaryFile() as graph,
|
|
|
157 |
|
158 |
G: nx.Graph = nx.read_edgelist(file.name, delimiter=delimiter, comments='\n', data=[('weight', float)])
|
159 |
|
160 |
+
mapping: Dict[Any, int] = {}
|
161 |
+
reverse: Dict[int, Any] = {}
|
162 |
|
163 |
for i, node in enumerate(G):
|
164 |
mapping[node] = i
|