From d9a88ea65faaa7a58ecee9b67d58bea55b042c33 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 19:51:56 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/uv-pre-commit: 0.9.5 → 0.12.7](https://github.com/astral-sh/uv-pre-commit/compare/0.9.5...0.12.7) - [github.com/astral-sh/ruff-pre-commit: v0.14.2 → v0.16.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.2...v0.16.5) - [github.com/pre-commit/mirrors-mypy: v1.18.2 → v2.3.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.18.2...v2.3.1) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5b8fd87..e046eca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/uv-pre-commit - rev: 0.9.5 + rev: 0.12.7 hooks: # Dependency management - id: uv-lock @@ -23,7 +23,7 @@ repos: # Python Linting & Formatting with Ruff - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.2 + rev: v0.16.5 hooks: - id: ruff name: ruff (linter) @@ -32,7 +32,7 @@ repos: name: ruff-format (formatter) - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.18.2 + rev: v2.3.1 hooks: - id: mypy args: [--strict] From 452cc35ab5ab77b9cc33e4669fb709e99e8b71c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 19:52:09 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.md | 16 +++---- docs/examples/basic.md | 24 +++++----- docs/examples/customization.md | 16 +++++-- docs/examples/directed.md | 80 +++++++++++++++++++++++----------- docs/usage.md | 10 ++--- 5 files changed, 91 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 5ccb0c6..cab56b9 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,12 @@ G = nx.cycle_graph(5) # Add some basic attributes for visualization for i, node_id in enumerate(G.nodes()): - G.nodes[node_id]['label'] = f'Node {i+1}' - G.nodes[node_id]['title'] = f'This is Node {i+1}' # Tooltip - G.nodes[node_id]['group'] = i % 2 + G.nodes[node_id]["label"] = f"Node {i + 1}" + G.nodes[node_id]["title"] = f"This is Node {i + 1}" # Tooltip + G.nodes[node_id]["group"] = i % 2 -G.edges[0,1]['label'] = 'Link 0-1' -G.edges[0,1]['color'] = 'red' +G.edges[0, 1]["label"] = "Link 0-1" +G.edges[0, 1]["color"] = "red" # 2. Define (optional) vis.js options custom_options = { @@ -63,10 +63,10 @@ custom_options = { "edges": {"smooth": {"enabled": True}}, "groups": { 0: {"color": "skyblue", "shape": "dot"}, - 1: {"color": "lightgreen", "shape": "square"} + 1: {"color": "lightgreen", "shape": "square"}, }, "interaction": {"navigationButtons": True, "hover": True}, - "physics": {"enabled": True} + "physics": {"enabled": True}, } # 3. Generate and show the interactive HTML graph @@ -76,7 +76,7 @@ nx_to_vis( output_filename="cycle_graph.html", html_title="My Interactive Cycle Graph", vis_options=custom_options, - show_browser=True + show_browser=True, ) # To get HTML for a Jupyter Notebook: diff --git a/docs/examples/basic.md b/docs/examples/basic.md index fffae05..ccbe1b7 100644 --- a/docs/examples/basic.md +++ b/docs/examples/basic.md @@ -23,15 +23,15 @@ import networkx as nx G = nx.cycle_graph(5) for i, node_id in enumerate(G.nodes()): - G.nodes[node_id]['label'] = f'N{i+1}' - G.nodes[node_id]['title'] = f'Tooltip for Node N{i+1}' - G.nodes[node_id]['group'] = i % 2 + G.nodes[node_id]["label"] = f"N{i + 1}" + G.nodes[node_id]["title"] = f"Tooltip for Node N{i + 1}" + G.nodes[node_id]["group"] = i % 2 if i == 0: - G.nodes[node_id]['color'] = 'skyblue' - G.nodes[node_id]['size'] = 25 -G.edges[0,1]['label'] = "Link 0-1" -G.edges[0,1]['color'] = "green" -G.edges[0,1]['width'] = 3 + G.nodes[node_id]["color"] = "skyblue" + G.nodes[node_id]["size"] = 25 +G.edges[0, 1]["label"] = "Link 0-1" +G.edges[0, 1]["color"] = "green" +G.edges[0, 1]["width"] = 3 ``` The `vis_options` used (as a Python dictionary in the generation script): @@ -72,10 +72,10 @@ import networkx as nx G = nx.karate_club_graph() for node_id, data in G.nodes(data=True): - data['label'] = str(node_id) - data['title'] = f"Member {node_id}\nClub: {data['club']}" - data['group'] = data['club'] - data['value'] = G.degree(node_id) + data["label"] = str(node_id) + data["title"] = f"Member {node_id}\nClub: {data['club']}" + data["group"] = data["club"] + data["value"] = G.degree(node_id) ``` The `vis_options` used (as a Python dictionary in the generation script): diff --git a/docs/examples/customization.md b/docs/examples/customization.md index 259bdfb..3a70755 100644 --- a/docs/examples/customization.md +++ b/docs/examples/customization.md @@ -31,6 +31,7 @@ The Python code to generate the graph structure can be found in `examples/advanc import networkx as nx import random + def create_showcase_graph(): G = nx.Graph(name="Advanced Showcase Graph") @@ -41,15 +42,22 @@ def create_showcase_graph(): shape="diamond", color={"background": "lightgreen", "border": "darkgreen"}, size=30, - fixed={"x": True, "y": True}, x=-400, y=-200, + fixed={"x": True, "y": True}, + x=-400, + y=-200, # ... other attributes ) # ... more nodes ... G.add_edge( - "Hub", "Sink", weight=5, color="blue", width=4, - title="Main link from Hub to Sink", arrows="to", - smooth={"type": "curvedCW", "roundness": 0.2} + "Hub", + "Sink", + weight=5, + color="blue", + width=4, + title="Main link from Hub to Sink", + arrows="to", + smooth={"type": "curvedCW", "roundness": 0.2}, ) # ... more edges ... return G diff --git a/docs/examples/directed.md b/docs/examples/directed.md index b633541..8297660 100644 --- a/docs/examples/directed.md +++ b/docs/examples/directed.md @@ -22,23 +22,25 @@ The Python code to generate the graph data: import networkx as nx DG = nx.DiGraph() -DG.add_edges_from([ - (1, 2, {'label': 'Rel A'}), - (1, 3, {'label': 'Rel B'}), - (2, 4, {'label': 'Rel C'}), - (3, 4, {'label': 'Rel D'}), - (4, 1, {'label': 'Rel E (Cycle)'}) # Creates a cycle -]) +DG.add_edges_from( + [ + (1, 2, {"label": "Rel A"}), + (1, 3, {"label": "Rel B"}), + (2, 4, {"label": "Rel C"}), + (3, 4, {"label": "Rel D"}), + (4, 1, {"label": "Rel E (Cycle)"}), # Creates a cycle + ] +) # Add some node properties for i in DG.nodes(): - DG.nodes[i]['label'] = f'DNode {i}' - DG.nodes[i]['title'] = f'This is directed node {i}' + DG.nodes[i]["label"] = f"DNode {i}" + DG.nodes[i]["title"] = f"This is directed node {i}" if i == 1: - DG.nodes[i]['color'] = 'lightcoral' - DG.nodes[i]['shape'] = 'star' + DG.nodes[i]["color"] = "lightcoral" + DG.nodes[i]["shape"] = "star" if i == 4: - DG.nodes[i]['color'] = 'lightgreen' + DG.nodes[i]["color"] = "lightgreen" ``` The `vis_options` used (as a Python dictionary in the generation script): @@ -86,25 +88,51 @@ import networkx as nx DG = nx.DiGraph() courses = { - "CS101": {"label": "Intro to CS", "level": 1, "title": "Fundamentals of Computer Science"}, - "CS102": {"label": "Data Structures", "level": 2, "title": "Basic Data Structures and Algorithms"}, - "MA101": {"label": "Calculus I", "level": 1, "title": "Differential Calculus"}, - "CS201": {"label": "Algorithms", "level": 3, "title": "Advanced Algorithm Design"}, - "CS202": {"label": "Operating Systems", "level": 3, "title": "Principles of Operating Systems"}, - "CS301": {"label": "Compilers", "level": 4, "title": "Compiler Construction"} + "CS101": { + "label": "Intro to CS", + "level": 1, + "title": "Fundamentals of Computer Science", + }, + "CS102": { + "label": "Data Structures", + "level": 2, + "title": "Basic Data Structures and Algorithms", + }, + "MA101": { + "label": "Calculus I", + "level": 1, + "title": "Differential Calculus", + }, + "CS201": { + "label": "Algorithms", + "level": 3, + "title": "Advanced Algorithm Design", + }, + "CS202": { + "label": "Operating Systems", + "level": 3, + "title": "Principles of Operating Systems", + }, + "CS301": { + "label": "Compilers", + "level": 4, + "title": "Compiler Construction", + }, } for course_id, attrs in courses.items(): DG.add_node(course_id, **attrs) # Edges: (prerequisite, course) -DG.add_edges_from([ - ("CS101", "CS102"), - ("MA101", "CS102"), - ("CS102", "CS201"), - ("CS102", "CS202"), - ("CS201", "CS301"), - ("CS202", "CS301") -]) +DG.add_edges_from( + [ + ("CS101", "CS102"), + ("MA101", "CS102"), + ("CS102", "CS201"), + ("CS102", "CS202"), + ("CS201", "CS301"), + ("CS202", "CS301"), + ] +) ``` The `vis_options` used (as a Python dictionary in the generation script): diff --git a/docs/usage.md b/docs/usage.md index 5b29458..5cafd96 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -13,17 +13,17 @@ from nx_vis_visualizer import nx_to_vis # 1. Create a NetworkX graph G = nx.Graph() G.add_edges_from([(1, 2), (2, 3), (3, 1), (3, 4)]) -G.nodes[1]['label'] = 'Node One' -G.nodes[2]['title'] = 'This is node 2, connected to 1 and 3.' # Tooltip -G.nodes[3]['color'] = 'red' -G.edges[2,3]['label'] = 'Link' +G.nodes[1]["label"] = "Node One" +G.nodes[2]["title"] = "This is node 2, connected to 1 and 3." # Tooltip +G.nodes[3]["color"] = "red" +G.edges[2, 3]["label"] = "Link" # 2. Visualize it! output_path = nx_to_vis( G, output_filename="my_first_graph.html", html_title="My First Interactive Graph", - show_browser=True # Automatically open the generated HTML in your browser + show_browser=True, # Automatically open the generated HTML in your browser ) print(f"Graph saved to: {output_path}")