praca_magisterska/main.py

25 lines
802 B
Python

def read_graph_from_file(path, separator=",", read_first_line=False, is_directed=False, has_weight=False):
edges = dict()
with open(path, 'r') as file:
read_line = read_first_line
line = file.readline()
while line != '':
if read_line:
if line[0] != "#":
split = line.split(separator)
node1 = int(split[0])
node2 = int(split[1])
if not is_directed:
if not has_weight:
edges[(node1, node2)] = 1
else:
read_line = True
line = file.readline()
return edges
if __name__ == '__main__':
e = read_graph_from_file("dataset/deezer_clean_data/HR_edges.csv")
print(e)