Loading autocnet/graph/network.py +4 −1 Changes for autocnet/graph/network.py: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ from plio.io.io_gdal import GeoDataset from autocnet.graph import markov_cluster from autocnet.graph.edge import Edge from autocnet.graph.node import Node from autocnet.vis.graph_view import plot_graph from autocnet.vis.graph_view import plot_graph, cluster_plot class CandidateGraph(nx.Graph): Loading Loading @@ -570,6 +570,9 @@ class CandidateGraph(nx.Graph): """ return plot_graph(self, ax=ax, **kwargs) def plot_cluster(self, ax=None, **kwargs): return cluster_plot(self, ax, **kwargs) def create_edge_subgraph(self, edges): """ Create a subgraph using a list of edges. Loading autocnet/vis/graph_view.py +33 −0 Changes for autocnet/vis/graph_view.py: 33 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -271,3 +271,36 @@ def plot_edge(edge, ax=None, clean_keys=[], image_space=100, ax.plot((l[0][0], l[1][0]), (l[0][1], l[1][1]), color=color, **line_kwargs) return ax def cluster_plot(graph, ax=None, cmap='Spectral'): """ Parameters ---------- graph ax cmap Returns ------- """ if ax is None: ax = plt.gca() if not hasattr(graph, 'clusters'): graph.compute_clusters() cmap = matplotlib.cm.get_cmap(cmap) colors = [] for i, n in graph.nodes_iter(data=True): for j in enumerate(graph.clusters): if i in graph.clusters.get(j[1]): colors.append(cmap(j[1])[0]) continue nx.draw(graph, ax=ax, node_color=colors) return ax Loading
autocnet/graph/network.py +4 −1 Changes for autocnet/graph/network.py: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ from plio.io.io_gdal import GeoDataset from autocnet.graph import markov_cluster from autocnet.graph.edge import Edge from autocnet.graph.node import Node from autocnet.vis.graph_view import plot_graph from autocnet.vis.graph_view import plot_graph, cluster_plot class CandidateGraph(nx.Graph): Loading Loading @@ -570,6 +570,9 @@ class CandidateGraph(nx.Graph): """ return plot_graph(self, ax=ax, **kwargs) def plot_cluster(self, ax=None, **kwargs): return cluster_plot(self, ax, **kwargs) def create_edge_subgraph(self, edges): """ Create a subgraph using a list of edges. Loading
autocnet/vis/graph_view.py +33 −0 Changes for autocnet/vis/graph_view.py: 33 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -271,3 +271,36 @@ def plot_edge(edge, ax=None, clean_keys=[], image_space=100, ax.plot((l[0][0], l[1][0]), (l[0][1], l[1][1]), color=color, **line_kwargs) return ax def cluster_plot(graph, ax=None, cmap='Spectral'): """ Parameters ---------- graph ax cmap Returns ------- """ if ax is None: ax = plt.gca() if not hasattr(graph, 'clusters'): graph.compute_clusters() cmap = matplotlib.cm.get_cmap(cmap) colors = [] for i, n in graph.nodes_iter(data=True): for j in enumerate(graph.clusters): if i in graph.clusters.get(j[1]): colors.append(cmap(j[1])[0]) continue nx.draw(graph, ax=ax, node_color=colors) return ax