-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEBFS.py
More file actions
28 lines (26 loc) · 936 Bytes
/
EBFS.py
File metadata and controls
28 lines (26 loc) · 936 Bytes
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
'''
EBFS.py
Implements the Exploration by Breadth-First Search graph reduction algorithm
author: Erik Rye
date: 14 June 15
'''
import exploration as ex
import networkx as nx
import os
def EBFS(graph, reduction_list, num_trials, verbose):
if not os.path.exists('EBFS/'):
os.mkdir('EBFS/')
for trial in range(num_trials):
if verbose:
print "Starting reduction w/seed " + str(trial) + "..."
for node_num in reduction_list:
reduced_graph = graph.copy()
if verbose:
print "Reducing to graph of order " + str(node_num) + "..."
e = ex.Exploration(reduced_graph,trial)
reduced_graph = e.EBFS(node_num)
nx.write_gexf(reduced_graph, 'EBFS/' + str(node_num) + '-EBFS-' +
str(trial) + '.gexf')
if verbose:
print "Graph of order " + str(node_num) + " written."
del e