from src.gimpy import Graph, UNDIRECTED_GRAPH except ImportError: from coinor.gimpy import Graph from pulp import LpVariable, lpSum, LpProblem, LpMaximize, LpMinimize, LpConstraint from pulp import LpStatus, value, LpBinary node_counts = {} numNodes = 30 numSeeds = 10 display = 'off' for b_rule in [MOST_FRACTIONAL, INTERDICTION_BRANCHING]: for seed in range(numSeeds): G = Graph(type=UNDIRECTED_GRAPH, splines='true', K=1.5) G.random(numnodes=numNodes, density=0.5, length_range=None, seedInput=seed) G.set_display_mode('off') nodes = G.get_node_list() T = InterdictionTree() T.set_display_mode(display) #Simple Heuristic IS = [-1 for i in nodes] for i in nodes: if IS[i] == -1: IS[i] = 1 for j in G.get_neighbors(i): IS[j] = 0
try: from src.gimpy import Graph, UNDIRECTED_GRAPH except ImportError: from coinor.gimpy import Graph, UNDIRECTED_GRAPH G = Graph(type = UNDIRECTED_GRAPH, splines = 'true', K = 1.5) G.random(numnodes = 10, Euclidean = True, seedInput = 11, #add_labels = True, #scale = 10, #scale_cost = 10, #degree_range = (2, 4), #length_range = (1, 10) ) G.set_display_mode('pygame') G.display() #G.dfs(0) G.search(0, display = 'pygame', algo = 'Dijkstra')