示例#1
0
    network.create_node(k_id, 3, k_type)
    network.create_node(s_id, 3, s_type)

print "Nodes created! Elapsed time: ", str(int(time.time() - start)), "s"

# Create edges
for index, row in ks_network.iterrows():
    k_id = str(row["S.ID"])
    s_id = str(row["K.ID"])

    network.create_edge(k_id, s_id, 2)

print "Edges created! Elapsed time: ", str(int(time.time() - start)), "s"

print network

# Convert to directed graph
network.convert_to_directed(10)
print "Bi-graph created! Elapsed time: ", str(int(time.time() - start)), "s"

# Formulate PCST
pcst = PCST(network, 1)

pcst.initialise()
print "LP created! Elapsed time: ", str(int(time.time() - start)), "s"

solution = pcst.optimise()
print "LP solved! Elapsed time: ", str(int(time.time() - start)), "s"

print solution.to_string()