|
1 | 1 | # Graph-Python-scripts |
2 | 2 |
|
3 | | -This repository is for testing Python Scripts |
| 3 | +This repository contains Python scripts for parsing meeting summaries and visualizing them as directed graphs using NetworkX and Matplotlib, plus exporting to GEXF for use in Gephi. |
| 4 | + |
| 5 | +## Contents |
| 6 | +- `Scripts/Nodes-Edges.py`: Build a directed graph from a single meeting summary and save `graph.png`. |
| 7 | +- `Scripts/Nodes-Edges2.py`: Build a directed graph from multiple meeting summaries and save `graph2.png`. |
| 8 | +- `Scripts/GEXF-export.py`: Build a comprehensive directed graph and export `all_workgroups_graph_sanitized.gexf`. |
| 9 | +- `Scripts/count.py`: Print top-level workgroup names from the remote JSON. |
| 10 | +- `Scripts/Import-JSON.py`: Generate `workgroup_meetings_summary.txt` with counts and meeting listings per workgroup. |
| 11 | +- `graph.png`, `graph2.png`: Example rendered graphs. |
| 12 | +- `Scripts/all_workgroups_graph_sanitized.gexf`: Example GEXF export ready for Gephi. |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | +- Python 3.9+ |
| 16 | +- Packages: |
| 17 | + - `requests` |
| 18 | + - `networkx` |
| 19 | + - `matplotlib` |
| 20 | + |
| 21 | +Install packages: |
4 | 22 |
|
5 | | -## Project Overview |
| 23 | +```bash |
| 24 | +pip install requests networkx matplotlib |
| 25 | +``` |
6 | 26 |
|
7 | | -This workspace contains Python scripts for visualizing meeting data as directed graphs using NetworkX and Matplotlib. |
| 27 | +## Data Source |
| 28 | +All scripts fetch JSON from a public URL: |
8 | 29 |
|
9 | | -### Nodes-Edges.py |
| 30 | +- `https://raw.githubusercontent.com/SingularityNET-Archive/SingularityNET-Archive/refs/heads/main/Data/Snet-Ambassador-Program/Meeting-Summaries/2025/meeting-summaries-array.json` |
10 | 31 |
|
11 | | -- **Purpose:** |
12 | | - Fetches a single meeting summary from a remote JSON file, parses its structure, and builds a directed graph representing relationships between workgroups, meetings, people, documents, agenda items, actions, decisions, tags, and emotions. |
13 | | -- **Key Steps:** |
14 | | - 1. Downloads JSON data from a URL. |
15 | | - 2. Handles both list and dict JSON structures. |
16 | | - 3. Safely extracts nested fields. |
17 | | - 4. Adds nodes and edges for all relevant entities. |
18 | | - 5. Saves the resulting graph visualization as `graph.png`. |
| 32 | +The scripts handle both top-level list and dict JSON structures. |
19 | 33 |
|
20 | | - |
| 34 | +## Usage |
| 35 | +Run scripts from the project root or the `Scripts/` directory. |
21 | 36 |
|
22 | | -### Nodes-Edges2.py |
| 37 | +### 1) Build a graph from a single meeting: `Scripts/Nodes-Edges.py` |
| 38 | +- Purpose: Parse one meeting object and produce a directed graph of relationships among workgroup, meeting, people, documents, agenda items, action items, decision items, tags, and emotions. |
| 39 | +- Output: Saves an image `graph.png` in the project root. |
23 | 40 |
|
24 | | -- **Purpose:** |
25 | | - Processes an array of meeting summaries from a remote JSON file, building a directed graph that includes all workgroups and their associated meetings, people, documents, agenda items, actions, decisions, tags, and emotions. |
26 | | -- **Key Steps:** |
27 | | - 1. Downloads JSON data from a URL. |
28 | | - 2. Handles both dict and list JSON structures, but always iterates through a list of workgroups. |
29 | | - 3. Safely extracts nested fields for each workgroup. |
30 | | - 4. Adds nodes and edges for all entities across all meetings. |
31 | | - 5. Saves the resulting graph visualization as `graph2.png`. |
| 41 | +Command: |
| 42 | +```bash |
| 43 | +python Scripts/Nodes-Edges.py |
| 44 | +``` |
32 | 45 |
|
33 | | - |
| 46 | +### 2) Build a graph from multiple meetings: `Scripts/Nodes-Edges2.py` |
| 47 | +- Purpose: Iterate all meetings/workgroups and build a combined directed graph. |
| 48 | +- Output: Saves `graph2.png` in the project root. |
34 | 49 |
|
35 | | ---- |
| 50 | +Command: |
| 51 | +```bash |
| 52 | +python Scripts/Nodes-Edges2.py |
| 53 | +``` |
36 | 54 |
|
37 | | -**Note:** |
38 | | -Both scripts reference `meeting-summaries-array.json` as their data source, **not** `meeting-summaries-by-id.json`. |
39 | | -They are designed for headless environments (such as dev containers). The graph images are saved to disk and can be viewed using the default browser with: |
| 55 | +### 3) Export a GEXF for Gephi: `Scripts/GEXF-export.py` |
| 56 | +- Purpose: Build a comprehensive, sanitized directed graph across all workgroups and export to GEXF. |
| 57 | +- Output: Writes `Scripts/all_workgroups_graph_sanitized.gexf`. |
40 | 58 |
|
| 59 | +Notes: |
| 60 | +- Ensures node IDs are strings and unique. |
| 61 | +- Sanitizes node/edge attributes to primitive types for GEXF compatibility. |
| 62 | +- Emits diagnostics (counts, sample nodes) before/after sanitization. |
| 63 | + |
| 64 | +Command: |
41 | 65 | ```bash |
42 | | -$BROWSER graph.png |
43 | | -$BROWSER graph2.png |
| 66 | +python Scripts/GEXF-export.py |
| 67 | +``` |
| 68 | + |
| 69 | +Open the GEXF in Gephi to explore the network. |
| 70 | + |
| 71 | +### 4) Quick inspection of workgroups: `Scripts/count.py` |
| 72 | +- Purpose: Print the `workgroup` field for each top-level item in the JSON (list or dict). |
| 73 | + |
| 74 | +Command: |
| 75 | +```bash |
| 76 | +python Scripts/count.py |
44 | 77 | ``` |
45 | 78 |
|
46 | | -### GEXF-Export Script |
47 | | -### GEXF-export.py |
| 79 | +### 5) Generate a text summary: `Scripts/Import-JSON.py` |
| 80 | +- Purpose: Create `workgroup_meetings_summary.txt` listing counts per workgroup and meeting info (date + title/type). |
| 81 | +- Output: `Scripts/workgroup_meetings_summary.txt`. |
| 82 | + |
| 83 | +Command: |
| 84 | +```bash |
| 85 | +python Scripts/Import-JSON.py |
| 86 | +``` |
48 | 87 |
|
49 | | -- **Purpose:** |
50 | | - Fetches all meeting summaries from a remote JSON file, builds a comprehensive directed graph of workgroups, meetings, people, documents, agenda items, actions, decisions, tags, and emotions, and exports the graph to a GEXF (Graph Exchange XML Format) file for further visualization and analysis in tools such as Gephi. |
| 88 | +## Outputs |
| 89 | +- `graph.png`: Single-meeting graph. |
| 90 | +- `graph2.png`: Multi-meeting graph. |
| 91 | +- `Scripts/all_workgroups_graph_sanitized.gexf`: GEXF for Gephi. |
| 92 | +- `Scripts/workgroup_meetings_summary.txt`: Human-readable summary. |
51 | 93 |
|
52 | | -- **Key Steps:** |
53 | | - 1. Downloads JSON data from a URL and normalizes it to a list of workgroups. |
54 | | - 2. Iterates through all workgroups, extracting and sanitizing relevant entities and relationships. |
55 | | - 3. Forces `meeting_node_id` to be unique by appending the top-level index when `workgroup_id` is missing or not unique. |
56 | | - 4. Ensures all node IDs are strings for compatibility. |
57 | | - 5. Adds nodes and edges for workgroups, meetings, people, documents, agenda items, actions, decisions, tags, and emotions. |
58 | | - 6. Sanitizes all node and edge attributes to ensure compatibility with the GEXF format. |
59 | | - 7. Prints counts of nodes and edges before and after sanitization, and prints sample node IDs so you can confirm the graph structure. |
60 | | - 8. Exports the resulting graph to `all_workgroups_graph_sanitized.gexf`. |
61 | | - 9. Optionally visualizes the graph in Python using Matplotlib. |
| 94 | +To preview generated images on macOS/Linux: |
| 95 | + |
| 96 | +```bash |
| 97 | +$BROWSER graph.png |
| 98 | +$BROWSER graph2.png |
| 99 | +``` |
62 | 100 |
|
63 | | -The script prints diagnostic information about the graph structure and attribute types before and after sanitization, ensuring the exported GEXF file is valid and ready for use in Gephi or other graph analysis tools. |
| 101 | +## Notes |
| 102 | +- All scripts are designed to run headlessly; graphs are saved to files instead of opening GUI windows. |
| 103 | +- The code uses defensive accessors and type checks to tolerate missing or differently shaped fields. |
| 104 | +- For reproducible layouts, the drawing functions use a fixed seed for `spring_layout` where applicable. |
0 commit comments