Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Gvisual/src/app/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Network {

/**
*
* Connects to database and writes out the edge-list from the meeting DB table, forming edges of kind:
* Connects to database and writes out the Edge-list from the meeting DB table, forming edges of kind:
* friends, classmates, study-groups, strangers and familiar strangers (depending upon parameters).
*
* <p>The output path is validated to prevent directory traversal —
Expand Down
30 changes: 15 additions & 15 deletions Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
/**
* Adjacency matrix heatmap visualization for graphs.
* Displays the graph as a colored matrix where cell intensity represents
* edge weight/presence, with edge-type color coding.
* Edge weight/presence, with Edge-type color coding.
*
* Features:
* - Color-coded cells by edge type (friend, classmate, familiar stranger, etc.)
* - Color-coded cells by Edge type (friend, classmate, familiar stranger, etc.)
* - Zoom and pan controls
* - Node reordering by degree, name, or community
* - Tooltip on hover showing node pair and edge details
* - Tooltip on hover showing node pair and Edge details
* - Export to PNG
*
* @author zalenix
*/
public class AdjacencyMatrixHeatmap extends JPanel {

private final Graph<String, edge> graph;
private final Graph<String, Edge> graph;
private List<String> nodeOrder;
private final Map<String, Map<String, edge>> adjacency;
private final Map<String, Map<String, Edge>> adjacency;
private int cellSize = 12;
private int offsetX = 0;
private int offsetY = 0;
Expand All @@ -49,7 +49,7 @@ public class AdjacencyMatrixHeatmap extends JPanel {
private static final Color HIGHLIGHT_COLOR = new Color(255, 255, 255, 40);
private static final Color LABEL_COLOR = new Color(200, 200, 200);

public AdjacencyMatrixHeatmap(Graph<String, edge> graph) {
public AdjacencyMatrixHeatmap(Graph<String, Edge> graph) {
this.graph = graph;
this.adjacency = new HashMap<>();
setBackground(BG_COLOR);
Expand All @@ -62,7 +62,7 @@ public AdjacencyMatrixHeatmap(Graph<String, edge> graph) {

private void buildAdjacency() {
adjacency.clear();
for (edge e : graph.getEdges()) {
for (Edge e : graph.getEdges()) {
String v1 = e.getVertex1();
String v2 = e.getVertex2();
adjacency.computeIfAbsent(v1, k -> new HashMap<>()).put(v2, e);
Expand Down Expand Up @@ -192,14 +192,14 @@ public String getToolTipText(MouseEvent e) {
if (hoveredRow.equals(hoveredCol)) {
return "Node: " + hoveredRow + " (degree: " + graph.degree(hoveredRow) + ")";
}
Map<String, edge> rowMap = adjacency.get(hoveredRow);
Map<String, Edge> rowMap = adjacency.get(hoveredRow);
if (rowMap != null && rowMap.containsKey(hoveredCol)) {
edge ed = rowMap.get(hoveredCol);
Edge ed = rowMap.get(hoveredCol);
String type = getEdgeTypeName(ed.getType());
String weight = ed.getWeight() != 0 ? ", weight: " + ed.getWeight() : "";
return hoveredRow + " ↔ " + hoveredCol + " [" + type + weight + "]";
}
return hoveredRow + " ↔ " + hoveredCol + " (no edge)";
return hoveredRow + " ↔ " + hoveredCol + " (no Edge)";
}
return null;
}
Expand All @@ -216,7 +216,7 @@ private String getEdgeTypeName(String type) {
}
}

private Color getEdgeColor(edge e) {
private Color getEdgeColor(Edge e) {
if (e == null) return DEFAULT_COLOR;
String type = e.getType();
if (type == null) return DEFAULT_COLOR;
Expand Down Expand Up @@ -269,9 +269,9 @@ protected void paintComponent(Graphics g2) {
int brightness = Math.min(255, 40 + deg * 15);
g.setColor(new Color(brightness, brightness, brightness));
} else {
Map<String, edge> rowMap = adjacency.get(nodeR);
Map<String, Edge> rowMap = adjacency.get(nodeR);
if (rowMap != null && rowMap.containsKey(nodeC)) {
edge e = rowMap.get(nodeC);
Edge e = rowMap.get(nodeC);
Color base = getEdgeColor(e);
float alpha = e.getWeight() > 0 ? Math.min(1f, 0.4f + e.getWeight() * 0.1f) : 0.85f;
g.setColor(new Color(base.getRed(), base.getGreen(), base.getBlue(),
Expand Down Expand Up @@ -347,7 +347,7 @@ protected void paintComponent(Graphics g2) {
};
for (int i = 0; i < legend.length; i++) {
int ly = legendY + 20 + i * 22;
edge dummy = new edge(legend[i][1], "", "");
Edge dummy = new Edge(legend[i][1], "", "");
g.setColor(getEdgeColor(dummy));
g.fillRect(legendX, ly - 10, 14, 14);
g.setColor(LABEL_COLOR);
Expand All @@ -366,7 +366,7 @@ protected void paintComponent(Graphics g2) {
/**
* Creates a dialog window containing the heatmap with controls.
*/
public static JDialog createDialog(JFrame parent, Graph<String, edge> graph) {
public static JDialog createDialog(JFrame parent, Graph<String, Edge> graph) {
JDialog dialog = new JDialog(parent, "Adjacency Matrix Heatmap", false);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

Expand Down
10 changes: 5 additions & 5 deletions Gvisual/src/gvisual/ArticulationPanelController.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ public class ArticulationPanelController {
private final JButton analyzeButton;
private final JButton clearButton;

private final Supplier<Graph<String, edge>> graphSupplier;
private final Supplier<Graph<String, Edge>> graphSupplier;
private final Runnable onOverlayChanged;

private boolean overlayActive;
private final Set<String> articulationPoints = new HashSet<>();
private final Set<edge> bridgeEdges = new HashSet<>();
private final Set<Edge> bridgeEdges = new HashSet<>();

/**
* @param graphSupplier supplies the current graph
* @param onOverlayChanged callback to refresh renderers/visualization after overlay changes
*/
public ArticulationPanelController(Supplier<Graph<String, edge>> graphSupplier,
public ArticulationPanelController(Supplier<Graph<String, Edge>> graphSupplier,
Runnable onOverlayChanged) {
this.graphSupplier = graphSupplier;
this.onOverlayChanged = onOverlayChanged;
Expand Down Expand Up @@ -78,10 +78,10 @@ public ArticulationPanelController(Supplier<Graph<String, edge>> graphSupplier,
public JPanel getPanel() { return panel; }
public boolean isOverlayActive() { return overlayActive; }
public Set<String> getArticulationPoints() { return Collections.unmodifiableSet(articulationPoints); }
public Set<edge> getBridgeEdges() { return Collections.unmodifiableSet(bridgeEdges); }
public Set<Edge> getBridgeEdges() { return Collections.unmodifiableSet(bridgeEdges); }

private void runAnalysis() {
Graph<String, edge> g = graphSupplier.get();
Graph<String, Edge> g = graphSupplier.get();
if (g == null || g.getVertexCount() == 0) {
summaryLabel.setText("<html>No graph loaded.</html>");
return;
Expand Down
50 changes: 25 additions & 25 deletions Gvisual/src/gvisual/ArticulationPointAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* <p>An <b>articulation point</b> is a vertex whose removal disconnects
* the graph (or increases its number of connected components). A
* <b>bridge</b> is an edge whose removal disconnects the graph.</p>
* <b>bridge</b> is an Edge whose removal disconnects the graph.</p>
*
* <p>These are critical elements for network reliability analysis:</p>
* <ul>
Expand All @@ -25,15 +25,15 @@
*/
public class ArticulationPointAnalyzer {

private final Graph<String, edge> graph;
private final Graph<String, Edge> graph;

/**
* Create a new analyzer for the given graph.
*
* @param graph the JUNG graph to analyze (must not be null)
* @throws IllegalArgumentException if graph is null
*/
public ArticulationPointAnalyzer(Graph<String, edge> graph) {
public ArticulationPointAnalyzer(Graph<String, Edge> graph) {
if (graph == null) {
throw new IllegalArgumentException("Graph must not be null");
}
Expand All @@ -43,16 +43,16 @@ public ArticulationPointAnalyzer(Graph<String, edge> graph) {
// ── Result classes ──────────────────────────────────────────

/**
* A bridge (cut edge) whose removal disconnects the graph.
* A bridge (cut Edge) whose removal disconnects the graph.
*/
public static class Bridge {
private final edge bridgeEdge;
private final Edge bridgeEdge;
private final String endpoint1;
private final String endpoint2;
private final int componentSizeA;
private final int componentSizeB;

public Bridge(edge bridgeEdge, String endpoint1, String endpoint2,
public Bridge(Edge bridgeEdge, String endpoint1, String endpoint2,
int componentSizeA, int componentSizeB) {
this.bridgeEdge = bridgeEdge;
this.endpoint1 = endpoint1;
Expand All @@ -61,8 +61,8 @@ public Bridge(edge bridgeEdge, String endpoint1, String endpoint2,
this.componentSizeB = componentSizeB;
}

/** The bridge edge. */
public edge getEdge() { return bridgeEdge; }
/** The bridge Edge. */
public Edge getEdge() { return bridgeEdge; }
/** One endpoint. */
public String getEndpoint1() { return endpoint1; }
/** Other endpoint. */
Expand Down Expand Up @@ -227,7 +227,7 @@ public AnalysisResult analyze() {
Map<String, String> parent = new HashMap<String, String>();
Set<String> visited = new HashSet<String>();
Set<String> articulationPoints = new LinkedHashSet<String>();
List<edge> bridgeEdges = new ArrayList<edge>();
List<Edge> bridgeEdges = new ArrayList<Edge>();
int[] timer = {0};

// Run DFS from each unvisited vertex (handles disconnected graphs)
Expand All @@ -245,7 +245,7 @@ public AnalysisResult analyze() {
for (String ap : articulationPoints) {
int degree = graph.degree(ap);
Map<String, Integer> edgeTypeCounts = new HashMap<String, Integer>();
for (edge e : graph.getIncidentEdges(ap)) {
for (Edge e : graph.getIncidentEdges(ap)) {
String type = e.getType() != null ? e.getType() : "unknown";
edgeTypeCounts.put(type, edgeTypeCounts.getOrDefault(type, 0) + 1);
}
Expand All @@ -260,7 +260,7 @@ public AnalysisResult analyze() {

// Build bridge details with component size estimation
List<Bridge> bridges = new ArrayList<Bridge>();
for (edge e : bridgeEdges) {
for (Edge e : bridgeEdges) {
String v1 = e.getVertex1() != null ? e.getVertex1() : findEndpoints(e)[0];
String v2 = e.getVertex2() != null ? e.getVertex2() : findEndpoints(e)[1];
int[] sizes = estimateComponentSizes(v1, v2, e);
Expand All @@ -284,7 +284,7 @@ private void dfs(String u,
Map<String, String> parent,
Set<String> visited,
Set<String> articulationPoints,
List<edge> bridges,
List<Edge> bridges,
int[] timer) {
visited.add(u);
disc.put(u, timer[0]);
Expand Down Expand Up @@ -314,23 +314,23 @@ private void dfs(String u,

// Bridge: low[v] > disc[u]
if (low.get(v) > disc.get(u)) {
edge bridgeEdge = findEdge(u, v);
Edge bridgeEdge = findEdge(u, v);
if (bridgeEdge != null) {
bridges.add(bridgeEdge);
}
}
} else if (!v.equals(parent.get(u))) {
// Back edge — update low value
// Back Edge — update low value
low.put(u, Math.min(low.get(u), disc.get(v)));
}
}
}

/**
* Find the edge connecting two vertices.
* Find the Edge connecting two vertices.
*/
private edge findEdge(String u, String v) {
for (edge e : graph.getIncidentEdges(u)) {
private Edge findEdge(String u, String v) {
for (Edge e : graph.getIncidentEdges(u)) {
String v1 = e.getVertex1();
String v2 = e.getVertex2();
// Also check via JUNG endpoints since vertex1/vertex2 may be null
Expand All @@ -346,9 +346,9 @@ private edge findEdge(String u, String v) {
}

/**
* Find endpoints of an edge via the graph when vertex1/vertex2 may be null.
* Find endpoints of an Edge via the graph when vertex1/vertex2 may be null.
*/
private String[] findEndpoints(edge e) {
private String[] findEndpoints(Edge e) {
Collection<String> endpoints = graph.getEndpoints(e);
if (endpoints != null && endpoints.size() == 2) {
Iterator<String> it = endpoints.iterator();
Expand Down Expand Up @@ -394,27 +394,27 @@ private int countBiconnectedComponents(String vertex) {

/**
* Estimate the sizes of the two components that would result from
* removing a bridge edge.
* removing a bridge Edge.
*/
private int[] estimateComponentSizes(String v1, String v2, edge bridgeEdge) {
// BFS from v1, excluding the bridge edge
private int[] estimateComponentSizes(String v1, String v2, Edge bridgeEdge) {
// BFS from v1, excluding the bridge Edge
Set<String> comp1 = bfsExcludingEdge(v1, bridgeEdge);
Set<String> comp2 = bfsExcludingEdge(v2, bridgeEdge);
return new int[]{comp1.size(), comp2.size()};
}

/**
* BFS from a start vertex, excluding a specific edge.
* BFS from a start vertex, excluding a specific Edge.
*/
private Set<String> bfsExcludingEdge(String start, edge excluded) {
private Set<String> bfsExcludingEdge(String start, Edge excluded) {
Set<String> visited = new HashSet<String>();
Queue<String> queue = new LinkedList<String>();
queue.add(start);
visited.add(start);

while (!queue.isEmpty()) {
String current = queue.poll();
for (edge e : graph.getIncidentEdges(current)) {
for (Edge e : graph.getIncidentEdges(current)) {
if (e == excluded) continue;
Collection<String> endpoints = graph.getEndpoints(e);
for (String neighbor : endpoints) {
Expand Down
14 changes: 7 additions & 7 deletions Gvisual/src/gvisual/BipartiteAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class BipartiteAnalyzer {
private static final String NIL = "__NIL__";
private static final int INF = Integer.MAX_VALUE;

private final Graph<String, edge> graph;
private final Graph<String, Edge> graph;
private Map<String, Integer> coloring;
private boolean bipartite;
private boolean computed;
Expand All @@ -45,7 +45,7 @@ public class BipartiteAnalyzer {
* @param graph the JUNG graph to analyze
* @throws IllegalArgumentException if graph is null
*/
public BipartiteAnalyzer(Graph<String, edge> graph) {
public BipartiteAnalyzer(Graph<String, Edge> graph) {
if (graph == null) {
throw new IllegalArgumentException("Graph must not be null");
}
Expand Down Expand Up @@ -224,7 +224,7 @@ public List<String> getOddCycle() {
// ── Maximum Matching (Hopcroft–Karp) ───────────────────────────

/**
* Represents a matching edge between two vertices.
* Represents a matching Edge between two vertices.
*/
public static class MatchingEdge {
private final String left;
Expand Down Expand Up @@ -427,7 +427,7 @@ public List<String> getMinimumVertexCover() {
}

// BFS alternating paths from unmatched left vertices
// Alternate: unmatched edge to right, matched edge back to left
// Alternate: unmatched Edge to right, matched Edge back to left
Set<String> visitedL = new LinkedHashSet<String>(unmatchedLeft);
Set<String> visitedR = new LinkedHashSet<String>();
Queue<String> queue = new LinkedList<String>(unmatchedLeft);
Expand All @@ -437,10 +437,10 @@ public List<String> getMinimumVertexCover() {
// Follow unmatched edges to right side
for (String n : graph.getNeighbors(l)) {
if (coloring.get(n) == RIGHT && !visitedR.contains(n)) {
// Only follow if this edge is NOT in the matching
// Only follow if this Edge is NOT in the matching
if (!n.equals(matchL.get(l))) {
visitedR.add(n);
// Follow matched edge back to left
// Follow matched Edge back to left
String partner = matchR.get(n);
if (partner != null && !visitedL.contains(partner)) {
visitedL.add(partner);
Expand Down Expand Up @@ -519,7 +519,7 @@ public double getPartitionBalance() {
}

/**
* Computes edge density of the bipartite graph.
* Computes Edge density of the bipartite graph.
* For bipartite graphs, max edges = |L| × |R|, so density = E / (|L| × |R|).
*
* @return density in [0, 1], or 0 for trivial cases
Expand Down
6 changes: 3 additions & 3 deletions Gvisual/src/gvisual/CentralityPanelController.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public class CentralityPanelController {
private final JButton computeButton;
private final JButton clearButton;

private final Supplier<Graph<String, edge>> graphSupplier;
private final Supplier<Graph<String, Edge>> graphSupplier;

private boolean active;
private final Map<String, NodeCentralityAnalyzer.CentralityResult> results = new HashMap<>();

public CentralityPanelController(Supplier<Graph<String, edge>> graphSupplier) {
public CentralityPanelController(Supplier<Graph<String, Edge>> graphSupplier) {
this.graphSupplier = graphSupplier;

Font labelFont = new Font("SansSerif", Font.PLAIN, 12);
Expand Down Expand Up @@ -106,7 +106,7 @@ public Map<String, NodeCentralityAnalyzer.CentralityResult> getResults() {
}

private void runAnalysis() {
Graph<String, edge> g = graphSupplier.get();
Graph<String, Edge> g = graphSupplier.get();
if (g == null || g.getVertexCount() == 0) {
summaryLabel.setText("<html>No graph loaded.</html>");
return;
Expand Down
Loading
Loading