Created
November 6, 2015 00:27
-
-
Save jeanpat/37bb8243b35c3a9fb658 to your computer and use it in GitHub Desktop.
Apply iterative prunings to a graph until no more vertice of degree 1 remains.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def total_length_graph(graph): | |
| v_ew, _ =vertex_degree1_edge_weight(T) | |
| return np.sum(v_ew.values()) | |
| def response_to_iterative_pruning(graph): | |
| '''return the number of vertices of degree 1 as a function of the number of pruning | |
| ''' | |
| response = [] | |
| response.append((0,number_of_degree1_vertices(graph))) | |
| #print number_of_degree1_vertices(graph) | |
| while number_of_degree1_vertices(graph)>0: | |
| #response.append(prune_graph_once(graph)) | |
| response.append(prune_once_faster(graph)) | |
| #print number_of_degree1_vertices(graph) | |
| data = np.array(response) | |
| #print data | |
| x = np.cumsum(data[:,0]) | |
| y = data[:,1] | |
| return x, y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment