-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (29 loc) · 1.05 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pandas as pd
import numpy as np
import os
from algorithms import *
import networkx as networkx
import matplotlib.pyplot as plt
import re
from utils import output_graph
import sys
np.set_printoptions(threshold=sys.maxsize)
def main():
for filename in os.listdir("./Project3 Dataset"):
df = pd.DataFrame()
node_edge = []
names = ['out','in']
if filename.startswith('ibm'):
with open("Project3 Dataset/ibm-5000.txt", 'r') as f:
for line in f.readlines():
line = line.strip()
edge = line.split()[1:]
node_edge.append(edge)
df = pd.DataFrame(node_edge, columns = names)
else:
df = pd.read_csv(f"Project3 Dataset/{filename}", header = None, names=names)
node_edge= df.values.tolist()
output_graph(filename, df)
# names = ['out','in']
# graph = pd.read_csv(f"Project3 Dataset/{filename}", header = None, names=names)
main()