repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/dataset/konect.py
xflow/dataset/konect.py
import os import networkx as nx import requests import random import tarfile import ndlib.models.ModelConfig as mc def create_folder(folder_name): if not os.path.exists(folder_name): os.makedirs(folder_name) def download_konect_dataset(url, filename): response = requests.get(url) if response.statu...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/dataset/eurostat.py
xflow/dataset/eurostat.py
import pandas as pd import networkx as nx import requests from io import BytesIO, StringIO import gzip def eurostat_road_go_ta_tg(): # URL of the Eurostat TSV file (compressed) eurostat_url = "https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/data/road_go_ta_tg/?format=TSV&compressed=true" # Downlo...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/dataset/nx.py
xflow/dataset/nx.py
import networkx as nx import random import ndlib.models.epidemics as ep import ndlib.models.ModelConfig as mc def connSW(n, beta=None): g = nx.connected_watts_strogatz_graph(n, 10, 0.1) config = mc.Configuration() for a, b in g.edges(): weight = random.randrange(40,80) weight = round(wei...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/dataset/snap.py
xflow/dataset/snap.py
import os import networkx as nx import requests import random import ndlib.models.ModelConfig as mc import gzip # TODO add CAIDA # https://snap.stanford.edu/data/as-caida.html def create_folder(folder_name): if not os.path.exists(folder_name): os.makedirs(folder_name) def download_snap_dataset(url, file...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/dataset/faf.py
xflow/dataset/faf.py
import pandas as pd import networkx as nx import requests from zipfile import ZipFile from io import BytesIO def faf5_6(): # URL of the CSV file within the ZIP archive zip_url = "https://faf.ornl.gov/faf5/data/download_files/FAF5.6.zip" # Download the ZIP file response = requests.get(zip_url) zip_...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/dataset/pyg.py
xflow/dataset/pyg.py
import networkx as nx import numpy as np import torch_geometric.datasets as ds import random import ndlib import ndlib.models.epidemics as ep import ndlib.models.ModelConfig as mc import torch_geometric from torch_geometric.datasets import Planetoid, EmailEUCore, MyketDataset, BitcoinOTC, PolBlogs, KarateClub from tor...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/dataset/__init__.py
xflow/dataset/__init__.py
__all__ = ['connSW', 'BA', 'ER', 'CiteSeer', 'PubMed', 'Cora', 'photo', 'coms']
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/IBM/graph_generation.py
xflow/IBM/graph_generation.py
import networkx as nx import torch_geometric.datasets as ds import random import ndlib import ndlib.models.epidemics as ep import ndlib.models.ModelConfig as mc from torch_geometric.datasets import Planetoid def connSW(n, beta=None): g = nx.connected_watts_strogatz_graph(n, 10, 0.1) config = mc.Configuration...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/IBM/main.py
xflow/IBM/main.py
from graph_generation import * from IBM_baselines import * from evaluation import * import time print('exp 1') g, config = connSW(1000, 0.1) print('connSW is on.') seeds = random.sample(list(g.nodes()), 10) print('seeds: ', seeds) beta = 0.1 for budget in [5, 10, 15, 20, 25, 30]: print('budget: ', budget) ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/IBM/evaluation.py
xflow/IBM/evaluation.py
import statistics as s from IBM_baselines import IC, LT, SI def blocking_effect_IC(g, config, seeds, selected_to_block): g_block = g.__class__() g_block.add_nodes_from(g) g_block.add_edges_from(g.edges) for a, b in g_block.edges(): weight = config.config["edges"]['threshold'][(a, b)] g...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/IBM/IBM_baselines.py
xflow/IBM/IBM_baselines.py
import networkx as nx import numpy as np import ndlib import ndlib.models.epidemics as ep import ndlib.models.ModelConfig as mc import statistics as s import random import matplotlib.pyplot as plt import numpy as np import pandas as pd import time import random # random # baselines: simulation based # greedy def gre...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/IM/graph_generation.py
xflow/IM/graph_generation.py
import networkx as nx import torch_geometric.datasets as ds import random import ndlib import ndlib.models.epidemics as ep import ndlib.models.ModelConfig as mc from torch_geometric.datasets import Planetoid def connSW(n, beta=None): g = nx.connected_watts_strogatz_graph(n, 10, 0.1) config = mc.Configuration...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/IM/IM_baselines.py
xflow/IM/IM_baselines.py
import networkx as nx import numpy as np import ndlib import ndlib.models.epidemics as ep import ndlib.models.ModelConfig as mc import statistics as s import random import matplotlib.pyplot as plt import numpy as np import pandas as pd import time from random import uniform, seed from collections import Counter import...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/IM/main.py
xflow/IM/main.py
import networkx as nx from time import time from graph_generation import Cora, CiteSeer, PubMed, connSW, ER, coms, photo from IM_baselines import eigen, degree, pi, sigma, greedy, celf, celfpp, IMRank, RIS from evaluation import effectSI def analyze(seed, beta, size): g, config = connSW(size, beta) print('bet...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/IM/evaluation.py
xflow/IM/evaluation.py
import networkx as nx import torch.nn.functional as F from torch_geometric.nn import GCNConv from torch_geometric.nn.inits import reset import random import numpy as np from torch_geometric import utils import ndlib.models.epidemics as ep import ndlib.models.ModelConfig as mc import statistics as s def effectIC(g, con...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/graph_generation.py
xflow/SL/graph_generation.py
import networkx as nx import torch_geometric.datasets as ds import ndlib.models.ModelConfig as mc import numpy as np import random from torch_geometric.datasets import Planetoid def CiteSeer(): dataset = Planetoid(root='./Planetoid', name='CiteSeer') # Cora, CiteSeer, PubMed data = dataset[0] edges = (da...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/Gaussian.py
xflow/SL/Gaussian.py
import networkx as nx from time import time from graphGeneration import Cora, CiteSeer, PubMed, connSW, ER, coms, photo from IM import eigen, degree, pi, sigma, Netshield, Soboldeg, Soboleigen, SobolPi, SobolSigma, SobolNS, greedyIC, degreeDis,SoboldegreeDis from score import effectIC import ndlib.models.ModelConfig a...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/main.py
xflow/SL/main.py
import networkx as nx import cosasi import random import numpy as np from graph_generation import CiteSeer, PubMed, Cora, coms, photo, connSW, rand from time import time import tracemalloc import logging # from memory_profiler import profile tracemalloc.start() # Create a logger logger = logging.getLogger() logger.se...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/__init__.py
xflow/SL/cosasi/__init__.py
from .contagion import * from .source_inference import * from .benchmark import *
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/benchmark/benchmark.py
xflow/SL/cosasi/benchmark/benchmark.py
import random import os, sys import json sys.path.insert(0, os.getcwd()) import numpy as np import networkx as nx import cosasi MODULE_PATH = __file__[: -len("benchmark.py")] MODULE_PATH = ( MODULE_PATH if len(MODULE_PATH) > 0 and (MODULE_PATH[-1] == "/" or MODULE_PATH[-1] == "\\") else MODULE_PATH + "/...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/benchmark/__init__.py
xflow/SL/cosasi/benchmark/__init__.py
from .benchmark import *
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/benchmark/tests/__init__.py
xflow/SL/cosasi/benchmark/tests/__init__.py
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/benchmark/tests/test_benchmark.py
xflow/SL/cosasi/benchmark/tests/test_benchmark.py
import os, sys sys.path.insert(0, os.getcwd()) import pytest from unittest import TestCase import networkx as nx import numpy as np import cosasi class Test_BenchmarkFromSimulation(TestCase): def setUp(self): self.number_infected_init = 3 self.sim_steps = 100 self.G = nx.fast_gnp_random...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/utils/estimators.py
xflow/SL/cosasi/utils/estimators.py
import math import random import warnings import scipy import numpy as np import networkx as nx from sklearn.cluster import SpectralClustering from .helpers import attack_degree, attack_degree_partition from ..source_inference.multiple_source import netsleuth def source_subgraphs(I, number_sources=2): """Subdiv...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/utils/helpers.py
xflow/SL/cosasi/utils/helpers.py
import operator import functools import numpy as np import networkx as nx def list_product(l): """Returns the product the elements of a list. Parameters ---------- l : list list of elements you want to multiply """ return functools.reduce(operator.mul, l, 1) def longest_list(l): ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/utils/__init__.py
xflow/SL/cosasi/utils/__init__.py
from .helpers import * from . import estimators
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/utils/tests/test_estimators.py
xflow/SL/cosasi/utils/tests/test_estimators.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import numpy as np import cosasi class TestEstimators(TestCase): def setUp(self): self.G = self.G = nx.gnp_random_graph(50, 0.2) contagion = cosasi.StaticNetworkContagion( ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/utils/tests/__init__.py
xflow/SL/cosasi/utils/tests/__init__.py
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/utils/tests/test_helpers.py
xflow/SL/cosasi/utils/tests/test_helpers.py
import os, sys sys.path.insert(0, os.getcwd()) import pytest import networkx as nx import numpy as np import random from cosasi import utils def test_list_product(): l = [1] assert utils.list_product(l) == 1 l += [2] assert utils.list_product(l) == 2 l += [-3] assert utils.list_product(l) =...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/contagion/static_network_contagion.py
xflow/SL/cosasi/contagion/static_network_contagion.py
import random import numpy as np import operator import networkx as nx import ndlib.models.epidemics as ep import ndlib.models.ModelConfig as mc class StaticNetworkContagion: """A stochastic epidemic process defined on a static network. Parameters ---------- G : NetworkX Graph The network fo...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/contagion/__init__.py
xflow/SL/cosasi/contagion/__init__.py
from .static_network_contagion import *
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/contagion/tests/__init__.py
xflow/SL/cosasi/contagion/tests/__init__.py
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/contagion/tests/test_static_network_contagion.py
xflow/SL/cosasi/contagion/tests/test_static_network_contagion.py
import os, sys import collections sys.path.insert(0, os.getcwd()) import pytest from unittest import TestCase import networkx as nx import numpy as np import cosasi class Test_StaticNetworkContagion(TestCase): def setUp(self): self.number_infected_init = 10 self.sim_steps = 10 self.G = ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/__init__.py
xflow/SL/cosasi/source_inference/__init__.py
from . import single_source from . import multiple_source
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/source_results.py
xflow/SL/cosasi/source_inference/source_results.py
"""Generic objects for the result of single-source and multi-source localization. All inference algorithms should return an instance of one of these classes. """ import json from collections import Counter from collections.abc import Iterable import itertools import numpy as np import networkx as nx MODULE_PATH = _...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/tests/test_source_results.py
xflow/SL/cosasi/source_inference/tests/test_source_results.py
import os, sys import pytest import itertools import random sys.path.insert(0, os.getcwd()) from unittest import TestCase import networkx as nx import numpy as np import cosasi from ..source_results import SourceResult, SingleSourceResult, MultiSourceResult, node_set_distance def test_node_set_distance(): G ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/tests/__init__.py
xflow/SL/cosasi/source_inference/tests/__init__.py
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/multiple_source/lisn.py
xflow/SL/cosasi/source_inference/multiple_source/lisn.py
import itertools import networkx as nx import numpy as np from ..source_results import MultiSourceResult from ...utils import estimators from .. import single_source def fast_multisource_lisn(I, G, t, number_sources=None): """Greedily runs single-source LISN algorithm on each estimated infection subgraph at...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/multiple_source/jordan.py
xflow/SL/cosasi/source_inference/multiple_source/jordan.py
import itertools import networkx as nx import numpy as np from ..source_results import MultiSourceResult from ...utils import estimators from .. import single_source def fast_multisource_jordan_centrality(I, G, number_sources=None): """Greedily runs single-source Jordan centrality on each estimated infection ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/multiple_source/netsleuth.py
xflow/SL/cosasi/source_inference/multiple_source/netsleuth.py
import itertools import networkx as nx import numpy as np from ..source_results import MultiSourceResult from ...utils import estimators from .. import single_source def netsleuth(I, G, hypotheses_per_step=1): """Implements the multi-source NETSLEUTH algorithm to score combinations of nodes in G. Param...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/multiple_source/__init__.py
xflow/SL/cosasi/source_inference/multiple_source/__init__.py
from .netsleuth import * from .jordan import * from .lisn import *
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/multiple_source/tests/test_netsleuth.py
xflow/SL/cosasi/source_inference/multiple_source/tests/test_netsleuth.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import numpy as np import random import math import cosasi class TestNETSLEUTH(TestCase): def setUp(self): self.G = nx.complete_graph(n=100) contagion = cosasi.StaticNetworkContagio...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/multiple_source/tests/test_lisn.py
xflow/SL/cosasi/source_inference/multiple_source/tests/test_lisn.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import cosasi class TestLISN(TestCase): def setUp(self): self.G = nx.complete_graph(n=100) contagion = cosasi.StaticNetworkContagion( G=self.G, model="si", infection_rat...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/multiple_source/tests/__init__.py
xflow/SL/cosasi/source_inference/multiple_source/tests/__init__.py
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/multiple_source/tests/test_jordan.py
xflow/SL/cosasi/source_inference/multiple_source/tests/test_jordan.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import cosasi class TestJordan(TestCase): def setUp(self): self.G = nx.complete_graph(n=100) contagion = cosasi.StaticNetworkContagion( G=self.G, model="si", infection_r...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/lisn.py
xflow/SL/cosasi/source_inference/single_source/lisn.py
import math import networkx as nx import numpy as np import scipy as sp from ..source_results import SingleSourceResult def lisn(I, G, t=None, infection_rate=0.1): """Implements the algorithm from Localizing the Information Source in a Network to score all nodes in G [1]_. Parameters ---------- ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/jordan.py
xflow/SL/cosasi/source_inference/single_source/jordan.py
import networkx as nx import numpy as np from ...utils import soft_eccentricity from ..source_results import SingleSourceResult def jordan_centrality(I, G): """Computes the infection eccentricity of each node in the infection subgraph. To produce a score with highest value corresponding to the Jordan center,...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/netsleuth.py
xflow/SL/cosasi/source_inference/single_source/netsleuth.py
import networkx as nx import numpy as np import warnings from ..source_results import SingleSourceResult def netsleuth(I, G): """Implements the single-source NETSLEUTH algorithm to score all nodes in G. Parameters ---------- I : NetworkX Graph The infection subgraph observed at a particular ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/__init__.py
xflow/SL/cosasi/source_inference/single_source/__init__.py
from .rumor_centrality import * from .short_fat_tree import * from .netsleuth import * from .jordan import * from .lisn import * from .earliest_infection_first import *
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/short_fat_tree.py
xflow/SL/cosasi/source_inference/single_source/short_fat_tree.py
import math import random import networkx as nx import numpy as np from ...utils import longest_list_len from ..source_results import SingleSourceResult def short_fat_tree(I, G, infection_rate=0.1): """Implements the Short-Fat-Tree (SFT) algorithm to score all nodes in G. Parameters ---------- I : ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/rumor_centrality.py
xflow/SL/cosasi/source_inference/single_source/rumor_centrality.py
import math import random import networkx as nx from ...utils import list_product from ..source_results import SingleSourceResult def rumor_centrality_root(I, v, return_all_values=True): """Computes rumor centrality for all nodes, assuming a spanning tree rooted at v. Parameters ---------- I : Netw...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/earliest_infection_first.py
xflow/SL/cosasi/source_inference/single_source/earliest_infection_first.py
import random import networkx as nx import numpy as np from ...utils import soft_eccentricity from ..source_results import SingleSourceResult def earliest_infection_first(I, G, observer_dict): """Implements the Earliest Infection First algorithm to score all nodes in I. This algorithm is useful if some inf...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/tests/test_netsleuth.py
xflow/SL/cosasi/source_inference/single_source/tests/test_netsleuth.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import numpy as np import random import math import cosasi class TestNETSLEUTH(TestCase): def setUp(self): self.G = nx.random_tree(n=500, seed=0) contagion = cosasi.StaticNetworkCon...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/tests/test_lisn.py
xflow/SL/cosasi/source_inference/single_source/tests/test_lisn.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import numpy as np import random import cosasi class TestLISN(TestCase): def setUp(self): self.G = nx.random_tree(n=500, seed=0) contagion = cosasi.StaticNetworkContagion( ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/tests/test_earliest_infection_first.py
xflow/SL/cosasi/source_inference/single_source/tests/test_earliest_infection_first.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import numpy as np import random import cosasi class TestEarliestInfectionFirst(TestCase): def setUp(self): self.G = nx.fast_gnp_random_graph(100, 0.25) contagion = cosasi.StaticNet...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/tests/test_short_fat_tree.py
xflow/SL/cosasi/source_inference/single_source/tests/test_short_fat_tree.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import numpy as np import random import math import cosasi class TestShortFatTree(TestCase): def setUp(self): self.G = nx.random_tree(n=500, seed=0) contagion = cosasi.StaticNetwork...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/tests/test_rumor_centrality.py
xflow/SL/cosasi/source_inference/single_source/tests/test_rumor_centrality.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import numpy as np import random import cosasi class TestRumorCentrality(TestCase): def setUp(self): self.G = nx.random_tree(n=500, seed=0) contagion = cosasi.StaticNetworkContagion...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/tests/__init__.py
xflow/SL/cosasi/source_inference/single_source/tests/__init__.py
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/xflow/SL/cosasi/source_inference/single_source/tests/test_jordan.py
xflow/SL/cosasi/source_inference/single_source/tests/test_jordan.py
import os, sys sys.path.insert(0, os.getcwd()) from unittest import TestCase import pytest import networkx as nx import numpy as np import cosasi class TestJordan(TestCase): def setUp(self): self.G = nx.random_tree(n=500, seed=0) contagion = cosasi.StaticNetworkContagion( G=self.G,...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/create_safe_traffic_lights.py
SUMOxPyPSA/create_safe_traffic_lights.py
#!/usr/bin/env python3 """ Create safe traffic light logic with proper coordination and random offsets """ import gzip import xml.etree.ElementTree as ET import os import random def create_safe_traffic_light_logic(signal_count, tl_id, junction_offset=0): """Create safe traffic light logic with proper coordination...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/fix_intersection_timing.py
SUMOxPyPSA/fix_intersection_timing.py
#!/usr/bin/env python3 """ Script to fix synchronized traffic lights at intersections by creating opposing logic """ import gzip import xml.etree.ElementTree as ET import os import re def analyze_intersection_traffic_lights(netfile): """Analyze traffic lights to find which ones are at the same intersection""" ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/compress_net.py
SUMOxPyPSA/compress_net.py
import gzip import shutil import os import sys def compress_file(input_file): """Compress a file using gzip compression""" if not os.path.exists(input_file): print(f"Error: File {input_file} does not exist") return False output_file = input_file + '.gz' try: with open(input...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/fix_traffic_synchronization.py
SUMOxPyPSA/fix_traffic_synchronization.py
#!/usr/bin/env python3 """ Script to fix traffic light synchronization by adding random offsets and varying phase durations """ import gzip import xml.etree.ElementTree as ET import os import random def create_desynchronized_traffic_light_logic(signal_count, tl_id): """Create traffic light logic with random offse...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/build.py
SUMOxPyPSA/build.py
#!/usr/bin/env python3 """ Unified build script for SUMO network generation """ import os import sys import subprocess from sumo_config import SUMO_COMMON_CONFIG, CITY_CONFIGS def run_command(cmd, cwd=None): """Run a shell command and print its output""" print(f"Running: {' '.join(cmd)}") process = subpro...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/desynchronize_traffic_lights.py
SUMOxPyPSA/desynchronize_traffic_lights.py
#!/usr/bin/env python3 """ Script to desynchronize traffic lights by adding random phase offsets """ import gzip import xml.etree.ElementTree as ET import os import random def extract_and_desynchronize_traffic_lights(netfile): """Extract traffic lights and add random offsets to desynchronize them""" traffic_l...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/generate_traffic_lights.py
SUMOxPyPSA/generate_traffic_lights.py
#!/usr/bin/env python3 """ Script to extract all traffic light IDs from network file and generate matching traffic_lights.add.xml """ import gzip import xml.etree.ElementTree as ET import os def extract_traffic_light_info(netfile): """Extract all traffic light IDs and their current phases from network file""" ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/modify_traffic_lights.py
SUMOxPyPSA/modify_traffic_lights.py
#!/usr/bin/env python3 """ Script to modify existing traffic light logic to separate straight and left-turn signals """ import gzip import xml.etree.ElementTree as ET import os import copy def analyze_traffic_light_structure(netfile): """Analyze current traffic light structure""" traffic_lights = {} conne...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/randomize_traffic_lights.py
SUMOxPyPSA/randomize_traffic_lights.py
#!/usr/bin/env python3 """ Script to randomize traffic light timing to break synchronization """ import gzip import xml.etree.ElementTree as ET import os import random def randomize_traffic_lights(netfile): """Extract traffic lights and randomize their timing""" traffic_lights = {} with gzip.open(net...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/regenerate_networks.py
SUMOxPyPSA/regenerate_networks.py
#!/usr/bin/env python3 """ Script to regenerate SUMO networks with updated traffic light configuration """ import os import subprocess import sys # Get SUMO binary path from config try: from config import SUMO_PATH NETCONVERT_BINARY = os.path.join(SUMO_PATH, "bin/netconvert") except ImportError: print("Er...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/config.py
SUMOxPyPSA/config.py
import os # SUMO Configuration # Modify these paths according to your system SUMO_PATH = "/usr/share/sumo" # Default for Linux # Alternative paths for different systems: # Windows: "C:\\Program Files (x86)\\Eclipse\\Sumo" # macOS: "/opt/homebrew/Cellar/sumo/1.20.0/share/sumo" # Web Server Configuration HOST = "0.0.0...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/fix_traffic_lights.py
SUMOxPyPSA/fix_traffic_lights.py
#!/usr/bin/env python3 """ Script to fix traffic light logic by adding all-red phases and ensuring proper cycling """ import gzip import xml.etree.ElementTree as ET import re import os def fix_traffic_light_logic(input_file, output_file): """ Fix traffic light logic by adding all-red phases between direction ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/fix_miami_traffic_lights.py
SUMOxPyPSA/fix_miami_traffic_lights.py
#!/usr/bin/env python3 """ Script to fix Miami traffic lights with proper logic for different signal group counts """ import gzip import xml.etree.ElementTree as ET import os def create_fixed_traffic_lights(netfile): """Create fixed traffic light logic that works for all signal group counts""" traffic_lights ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/map_to_power.py
SUMOxPyPSA/map_to_power.py
import os import subprocess import pandas as pd import sys def find_python_executable(): """Find the appropriate Python executable to use.""" # Try different possible Python executables python_candidates = [ '/bin/python', '/usr/bin/python', '/usr/bin/python3', 'python3', ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/app.py
SUMOxPyPSA/app.py
from flask import Flask, render_template, send_from_directory from flask_socketio import SocketIO, emit import traci import time import threading import os import sys import tempfile from config import * from sumo_config import SUMO_COMMON_CONFIG, CITY_CONFIGS as SUMO_CITY_CONFIGS app = Flask(__name__, static_url_path...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/sumo_config.py
SUMOxPyPSA/sumo_config.py
""" Unified SUMO configuration settings for all cities """ import os # Base directory is where this file is located BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # Common configuration settings for all cities SUMO_COMMON_CONFIG = { 'processing': { 'time-to-teleport': '300', 'collision.act...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/gridkit.py
SUMOxPyPSA/tools/gridkit.py
#!/usr/bin/env python """GridKit is a power grid extraction toolkit. Usage: python gridkit.py path/to/data-file.osm --filter \\ --poly path/to/area.poly \\ --pg user=gridkit database=gridkit GridKit will create a database, import the power data, run the extraction procedures, and write CSV's wit...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/util/geojson-to-postgis.py
SUMOxPyPSA/tools/util/geojson-to-postgis.py
#!/usr/bin/env python from __future__ import print_function, unicode_literals import operator import psycopg2 import psycopg2.extras import io import json import sys import logging CREATE_TABLES = ''' CREATE EXTENSION IF NOT EXISTS hstore; CREATE EXTENSION IF NOT EXISTS postgis; DROP TABLE IF EXISTS feature_points; D...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/util/network.py
SUMOxPyPSA/tools/util/network.py
from __future__ import unicode_literals, division, print_function import io import csv import random import itertools import heapq import math import warnings try: from recordclass import recordclass except ImportError: from collections import namedtuple as recordclass warnings.warn("recordclass is necessar...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/util/load_polyfile.py
SUMOxPyPSA/tools/util/load_polyfile.py
#!/usr/bin/env python from __future__ import print_function, unicode_literals, division import argparse import sys import os import io from polyfile import PolyfileParser from geometry import Polygon ap = argparse.ArgumentParser() ap.add_argument('file', nargs='+', type=str) ap.add_argument('--table', type=str, defaul...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/util/postgres.py
SUMOxPyPSA/tools/util/postgres.py
from .which import which try: import psycopg2 import psycopg2.extensions except ImportError: psycopg2 = False PSQL = which('psql') class QueryError(Exception): def __init__(self, error, query): super(QueryError, self).__init__(error) self.query = query def make_copy_query(subque...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/util/polyfile.py
SUMOxPyPSA/tools/util/polyfile.py
import re # syntax of poly files; # name # number # indented list of longitude, latitude # end # possibly another number # another end class PolyfileParser(object): newline = re.compile(r'\s*\n') whitespace = re.compile(r'\s+') end = re.compile(r'END') word = re.compile(r'\w+') ...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/util/__init__.py
SUMOxPyPSA/tools/util/__init__.py
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/util/geometry.py
SUMOxPyPSA/tools/util/geometry.py
from __future__ import print_function, division import collections def cross_vertical(line_d, line_v): pt_d1, pt_d2 = line_d pt_v1, pt_v2 = line_v x_d1, y_d1 = pt_d1 x_d2, y_d2 = pt_d2 dy_d = y_d2 - y_d1 dx_d = x_d2 - x_d1 if dx_d == 0: # parallel (vertical) line return No...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/util/which.py
SUMOxPyPSA/tools/util/which.py
import os def which(program): '''Find executable for a given name by PATH, or None if no executable could be found''' if os.name == 'nt': return _nt_which(program) elif os.name == 'posix': return _posix_which(program) raise NotImplementedError(os.platform) def _nt_which(program): P...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/tools/util/hstore.py
SUMOxPyPSA/tools/util/hstore.py
import re class hstore(dict): class parser(object): word = re.compile(r'"([^"]+)"') arrow = re.compile(r'\s*=>\s*') comma = re.compile(r',\s*') def __init__(self, text): self.position = 0 self.text = text def __iter__(self): whil...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/miami/check_tls_id_mismatches.py
SUMOxPyPSA/miami/check_tls_id_mismatches.py
import gzip import xml.etree.ElementTree as ET def get_tllogic_ids_from_net(netfile): ids = set() with gzip.open(netfile, 'rt', encoding='utf-8') as f: tree = ET.parse(f) root = tree.getroot() for tl in root.findall('tlLogic'): tid = tl.get('id') if tid is not No...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/SUMOxPyPSA/miami/extract_tllogic.py
SUMOxPyPSA/miami/extract_tllogic.py
import gzip import xml.etree.ElementTree as ET def extract_tllogics(filename): with gzip.open(filename, 'rt', encoding='utf-8') as f: tree = ET.parse(f) root = tree.getroot() for tl in root.findall('tlLogic'): print(f"\n<tlLogic id=\"{tl.get('id')}\" type=\"{tl.get('type')}\" pr...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/examples/xflow_loader.py
examples/xflow_loader.py
import sys import os current_script_directory = os.path.dirname(os.path.abspath(__file__)) xflow_path = os.path.join(current_script_directory, '..', '..', 'xflow') sys.path.insert(1, xflow_path)
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/examples/main.py
examples/main.py
import xflow_loader from xflow.dataset.nx import BA, connSW from xflow.dataset.pyg import Cora from xflow.diffusion import SI, IC, LT from xflow.seed import random as seed_random, degree as seed_degree, eigen as seed_eigen from xflow.util import run # graphs to test fn = lambda: connSW(n=1000, beta=0.1) fn.__name__ =...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/examples/__init__.py
examples/__init__.py
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
XGraph-Team/XFlow
https://github.com/XGraph-Team/XFlow/blob/1efc1844d3940fb726324c2a72c5f4325690910a/examples/FlowTaskEx1.py
examples/FlowTaskEx1.py
from FlowTasks import forward, backward, graph_eval # ### Testing / Examples # a FW1 dataset, with the observations stored as attributes to a networkx graph # In[23]: output = forward(1, obs_type = 'networkx', num_results=5) #print observation type print('Observations are of type:', type(output[0]['observations...
python
MIT
1efc1844d3940fb726324c2a72c5f4325690910a
2026-01-05T07:14:40.788228Z
false
androidtrackers/certified-android-devices
https://github.com/androidtrackers/certified-android-devices/blob/47d470ee2a5633a17c31c22c53641c62fcb18519/sync.py
sync.py
#!/usr/bin/env -S uv run --script # /// script # dependencies = [ # "requests<3", # ] # /// """Google certified android devices tracker""" import difflib import json import sys from datetime import date from os import environ, system from pathlib import Path from time import sleep from requests import get, post GI...
python
MIT
47d470ee2a5633a17c31c22c53641c62fcb18519
2026-01-05T07:03:50.578463Z
false
inigodelportillo/ITU-Rpy
https://github.com/inigodelportillo/ITU-Rpy/blob/e69587f75bdb7f8b1049259f36eb31a36ca5c570/setup.py
setup.py
"""A setuptools based setup module for ITUR-py.""" # Always prefer setuptools over distutils from setuptools import setup, find_packages # To use a consistent encoding from codecs import open as open_codecs from os import path import itur here = path.abspath(path.dirname(__file__)) # Get the long description from t...
python
MIT
e69587f75bdb7f8b1049259f36eb31a36ca5c570
2026-01-05T07:12:38.084174Z
false
inigodelportillo/ITU-Rpy
https://github.com/inigodelportillo/ITU-Rpy/blob/e69587f75bdb7f8b1049259f36eb31a36ca5c570/itur/plotting.py
itur/plotting.py
# -*- coding: utf-8 -*- """``itur.plotting`` provides convenient function to plot maps in ITU-Rpy. This submodule uses ``matplotlib`` and ``cartopy`` as the default library to plot maps. Alternatively, the user can use ``basemap`` (if installed). The example below shows the use of ``plot_in_map`` to display the mean ...
python
MIT
e69587f75bdb7f8b1049259f36eb31a36ca5c570
2026-01-05T07:12:38.084174Z
false
inigodelportillo/ITU-Rpy
https://github.com/inigodelportillo/ITU-Rpy/blob/e69587f75bdb7f8b1049259f36eb31a36ca5c570/itur/utils.py
itur/utils.py
# -*- coding: utf-8 -*- """ ``itur.utils`` is a utilities library for ITU-Rpy. This utility library for ITU-Rpy contains methods to: * Load data and build an interpolator object. * Prepare the input and output arrays, and handle unit transformations. * Compute distances and elevation angles between two points on Eart...
python
MIT
e69587f75bdb7f8b1049259f36eb31a36ca5c570
2026-01-05T07:12:38.084174Z
false
inigodelportillo/ITU-Rpy
https://github.com/inigodelportillo/ITU-Rpy/blob/e69587f75bdb7f8b1049259f36eb31a36ca5c570/itur/__init__.py
itur/__init__.py
# -*- coding: utf-8 -*- """ ITU-RPy is a python implementation of the ITU-P R Recommendations. ITU-Rpy can be used to compute atmospheric attenuation for Earth-to-space and horizontal paths, for frequencies in the GHz range. The propagation loss on an Earth-space path and a horizontal-path, relative to the free-space...
python
MIT
e69587f75bdb7f8b1049259f36eb31a36ca5c570
2026-01-05T07:12:38.084174Z
false
inigodelportillo/ITU-Rpy
https://github.com/inigodelportillo/ITU-Rpy/blob/e69587f75bdb7f8b1049259f36eb31a36ca5c570/itur/__version__.py
itur/__version__.py
# -*- coding: utf-8 -*- """Version information.""" # The following line *must* be the last in the module, exactly as formatted: __version__ = "0.4.0"
python
MIT
e69587f75bdb7f8b1049259f36eb31a36ca5c570
2026-01-05T07:12:38.084174Z
false
inigodelportillo/ITU-Rpy
https://github.com/inigodelportillo/ITU-Rpy/blob/e69587f75bdb7f8b1049259f36eb31a36ca5c570/itur/models/itu838.py
itur/models/itu838.py
# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from astropy import units as u from itur.utils import prepare_quantity class __ITU838__(): """Specific attenuation model for rain for use in prediction methods ...
python
MIT
e69587f75bdb7f8b1049259f36eb31a36ca5c570
2026-01-05T07:12:38.084174Z
false
inigodelportillo/ITU-Rpy
https://github.com/inigodelportillo/ITU-Rpy/blob/e69587f75bdb7f8b1049259f36eb31a36ca5c570/itur/models/itu1144.py
itur/models/itu1144.py
# -*- coding: utf-8 -*- """ Interpolation methods for the geophysical properties used to compute propagation effects. These methods are based on those in Recommendation ITU-R P.1144-7. References -------- [1] Guide to the application of the propagation methods of Radiocommunication Study Group 3: https://www.itu.int/r...
python
MIT
e69587f75bdb7f8b1049259f36eb31a36ca5c570
2026-01-05T07:12:38.084174Z
false
inigodelportillo/ITU-Rpy
https://github.com/inigodelportillo/ITU-Rpy/blob/e69587f75bdb7f8b1049259f36eb31a36ca5c570/itur/models/itu837.py
itur/models/itu837.py
# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from astropy import units as u from scipy.optimize import bisect import scipy.stats as stats from itur.models.itu1510 import surface_month_mean_temperature from itur...
python
MIT
e69587f75bdb7f8b1049259f36eb31a36ca5c570
2026-01-05T07:12:38.084174Z
false