Loading autocnet/graph/network.py +14 −59 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ import os from time import gmtime, strftime import warnings import dill as pickle import networkx as nx import pandas as pd Loading Loading @@ -81,24 +80,6 @@ class CandidateGraph(nx.Graph): eq = False return eq @classmethod def from_graph(cls, graph): """ Return a graph object from a pickled file Parameters ---------- graph : str PATH to the graph object Returns ------- graph : object CandidateGraph object """ with open(graph, 'rb') as f: graph = pickle.load(f) return graph @classmethod def from_filelist(cls, filelist, basepath=None): """ Loading Loading @@ -287,7 +268,6 @@ class CandidateGraph(nx.Graph): """ self.apply_func_to_edges('match', *args, **kwargs) def decompose_and_match(self, *args, **kwargs): """ For all edges in the graph, apply coupled decomposition followed by Loading Loading @@ -344,6 +324,20 @@ class CandidateGraph(nx.Graph): cycles.append((s,d,n)) return cycles def minimum_spanning_tree(self): """ Calculates the minimum spanning tree of the graph Returns ------- : DataFrame boolean mask for edges in the minimum spanning tree """ mst = nx.minimum_spanning_tree(self) return self.create_edge_subgraph(mst.edges()) def apply_func_to_edges(self, function, *args, **kwargs): """ Iterates over edges using an optional mask and and applies the given function. Loading Loading @@ -405,16 +399,6 @@ class CandidateGraph(nx.Graph): ''' self.apply_func_to_edges('compute_fundamental_matrix', *args, **kwargs) def refine_fundamental_matrix_matches(self, *args, **kwargs): """ Refine the fundamental matrix matches using reprojective error See Also -------- autocnet.transformation.transformations.FundamentalMatrix.refine_matches """ self.apply_func_to_edges('refine_fundamental_matrix_matches', *args, **kwargs) def subpixel_register(self, *args, **kwargs): ''' Compute subpixel offsets for all edges using identical parameters Loading Loading @@ -445,20 +429,6 @@ class CandidateGraph(nx.Graph): ''' self.apply_func_to_edges('overlap') def minimum_spanning_tree(self): """ Calculates the minimum spanning tree of the graph Returns ------- : DataFrame boolean mask for edges in the minimum spanning tree """ mst = nx.minimum_spanning_tree(self) return self.create_edge_subgraph(mst.edges()) def to_filelist(self): """ Generate a file list for the entire graph. Loading Loading @@ -493,21 +463,6 @@ class CandidateGraph(nx.Graph): self.cn = [n.point_to_correspondence_df for i, n in self.nodes_iter(data=True) if isinstance(n.point_to_correspondence_df, pd.DataFrame)] def to_json_file(self, outputfile): """ Write the edge structure to a JSON adjacency list Parameters ---------- outputfile : str PATH where the JSON will be written """ adjacency_dict = {} for n in self.nodes(): adjacency_dict[n] = self.neighbors(n) io_json.write_json(adjacency_dict, outputfile) def island_nodes(self): """ Finds single nodes that are completely disconnected from the rest of the graph Loading Loading
autocnet/graph/network.py +14 −59 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ import os from time import gmtime, strftime import warnings import dill as pickle import networkx as nx import pandas as pd Loading Loading @@ -81,24 +80,6 @@ class CandidateGraph(nx.Graph): eq = False return eq @classmethod def from_graph(cls, graph): """ Return a graph object from a pickled file Parameters ---------- graph : str PATH to the graph object Returns ------- graph : object CandidateGraph object """ with open(graph, 'rb') as f: graph = pickle.load(f) return graph @classmethod def from_filelist(cls, filelist, basepath=None): """ Loading Loading @@ -287,7 +268,6 @@ class CandidateGraph(nx.Graph): """ self.apply_func_to_edges('match', *args, **kwargs) def decompose_and_match(self, *args, **kwargs): """ For all edges in the graph, apply coupled decomposition followed by Loading Loading @@ -344,6 +324,20 @@ class CandidateGraph(nx.Graph): cycles.append((s,d,n)) return cycles def minimum_spanning_tree(self): """ Calculates the minimum spanning tree of the graph Returns ------- : DataFrame boolean mask for edges in the minimum spanning tree """ mst = nx.minimum_spanning_tree(self) return self.create_edge_subgraph(mst.edges()) def apply_func_to_edges(self, function, *args, **kwargs): """ Iterates over edges using an optional mask and and applies the given function. Loading Loading @@ -405,16 +399,6 @@ class CandidateGraph(nx.Graph): ''' self.apply_func_to_edges('compute_fundamental_matrix', *args, **kwargs) def refine_fundamental_matrix_matches(self, *args, **kwargs): """ Refine the fundamental matrix matches using reprojective error See Also -------- autocnet.transformation.transformations.FundamentalMatrix.refine_matches """ self.apply_func_to_edges('refine_fundamental_matrix_matches', *args, **kwargs) def subpixel_register(self, *args, **kwargs): ''' Compute subpixel offsets for all edges using identical parameters Loading Loading @@ -445,20 +429,6 @@ class CandidateGraph(nx.Graph): ''' self.apply_func_to_edges('overlap') def minimum_spanning_tree(self): """ Calculates the minimum spanning tree of the graph Returns ------- : DataFrame boolean mask for edges in the minimum spanning tree """ mst = nx.minimum_spanning_tree(self) return self.create_edge_subgraph(mst.edges()) def to_filelist(self): """ Generate a file list for the entire graph. Loading Loading @@ -493,21 +463,6 @@ class CandidateGraph(nx.Graph): self.cn = [n.point_to_correspondence_df for i, n in self.nodes_iter(data=True) if isinstance(n.point_to_correspondence_df, pd.DataFrame)] def to_json_file(self, outputfile): """ Write the edge structure to a JSON adjacency list Parameters ---------- outputfile : str PATH where the JSON will be written """ adjacency_dict = {} for n in self.nodes(): adjacency_dict[n] = self.neighbors(n) io_json.write_json(adjacency_dict, outputfile) def island_nodes(self): """ Finds single nodes that are completely disconnected from the rest of the graph Loading