Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making node colors static across clusters #530

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
self.counter = 0
self.logger = logger
self.color_map = {}
self.cluster_specific_id_types = None
joker2411 marked this conversation as resolved.
Show resolved Hide resolved

def get_edges_data(self, node_id: str) -> pd.DataFrame:
cluster_query_template = """
Expand Down Expand Up @@ -317,10 +318,6 @@ def _visualize_large_graph(self, G: nx.Graph, file_path: str):
def _pre_compute_graph_info(self, G: nx.Graph):
degrees = dict(G.degree())
max_degree = max(degrees.values()) if degrees else 0
id_types = set(nx.get_node_attributes(G, "id_type").values())

if not self.color_map:
self.color_map = self._generate_color_map(id_types)
return degrees, max_degree

def _initialise_network(self):
Expand All @@ -345,6 +342,7 @@ def _add_legend_to_file(self, file_path):
</div>
"""
for id_type, color in self.color_map.items()
if id_type in self.cluster_specific_id_types
]

legend_html = f"""
Expand Down Expand Up @@ -382,6 +380,9 @@ def run(self):
"You can explore specific clusters by entering an ID to see how the other ids are all connected and the cluster is formed."
)
print("The ID can be either the main ID or any other ID type.")
self.color_map = self._generate_color_map(
self.table_report.analysis_results["node_types"]
)
output_dir = os.path.join(os.getcwd(), "graph_outputs")
while True:
user_input = self.reader.get_input(
Expand All @@ -392,6 +393,9 @@ def run(self):
break
print("\n\n")
metrics, G = self._analyse_cluster(user_input)
self.cluster_specific_id_types = set(
joker2411 marked this conversation as resolved.
Show resolved Hide resolved
nx.get_node_attributes(G, "id_type").values()
)
if metrics is None:
continue
cluster_summary = self.get_cluster_summary(metrics)
Expand Down
Loading