diff --git a/Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java b/Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java index 8ce1273..4d6e347 100644 --- a/Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java +++ b/Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java @@ -26,9 +26,9 @@ */ public class AdjacencyMatrixHeatmap extends JPanel { - private final Graph graph; + private final Graph graph; private List nodeOrder; - private final Map> adjacency; + private final Map> adjacency; private int cellSize = 12; private int offsetX = 0; private int offsetY = 0; @@ -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 graph) { + public AdjacencyMatrixHeatmap(Graph graph) { this.graph = graph; this.adjacency = new HashMap<>(); setBackground(BG_COLOR); @@ -62,7 +62,7 @@ public AdjacencyMatrixHeatmap(Graph 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); @@ -192,7 +192,7 @@ public String getToolTipText(MouseEvent e) { if (hoveredRow.equals(hoveredCol)) { return "Node: " + hoveredRow + " (degree: " + graph.degree(hoveredRow) + ")"; } - Map rowMap = adjacency.get(hoveredRow); + Map rowMap = adjacency.get(hoveredRow); if (rowMap != null && rowMap.containsKey(hoveredCol)) { edge ed = rowMap.get(hoveredCol); String type = getEdgeTypeName(ed.getType()); @@ -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; @@ -269,7 +269,7 @@ protected void paintComponent(Graphics g2) { int brightness = Math.min(255, 40 + deg * 15); g.setColor(new Color(brightness, brightness, brightness)); } else { - Map rowMap = adjacency.get(nodeR); + Map rowMap = adjacency.get(nodeR); if (rowMap != null && rowMap.containsKey(nodeC)) { edge e = rowMap.get(nodeC); Color base = getEdgeColor(e); @@ -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); @@ -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 graph) { + public static JDialog createDialog(JFrame parent, Graph graph) { JDialog dialog = new JDialog(parent, "Adjacency Matrix Heatmap", false); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); diff --git a/Gvisual/src/gvisual/ArticulationPanelController.java b/Gvisual/src/gvisual/ArticulationPanelController.java index c1d01a3..15c90a6 100644 --- a/Gvisual/src/gvisual/ArticulationPanelController.java +++ b/Gvisual/src/gvisual/ArticulationPanelController.java @@ -22,18 +22,18 @@ public class ArticulationPanelController { private final JButton analyzeButton; private final JButton clearButton; - private final Supplier> graphSupplier; + private final Supplier> graphSupplier; private final Runnable onOverlayChanged; private boolean overlayActive; private final Set articulationPoints = new HashSet<>(); - private final Set bridgeEdges = new HashSet<>(); + private final Set bridgeEdges = new HashSet<>(); /** * @param graphSupplier supplies the current graph * @param onOverlayChanged callback to refresh renderers/visualization after overlay changes */ - public ArticulationPanelController(Supplier> graphSupplier, + public ArticulationPanelController(Supplier> graphSupplier, Runnable onOverlayChanged) { this.graphSupplier = graphSupplier; this.onOverlayChanged = onOverlayChanged; @@ -78,10 +78,10 @@ public ArticulationPanelController(Supplier> graphSupplier, public JPanel getPanel() { return panel; } public boolean isOverlayActive() { return overlayActive; } public Set getArticulationPoints() { return Collections.unmodifiableSet(articulationPoints); } - public Set getBridgeEdges() { return Collections.unmodifiableSet(bridgeEdges); } + public Set getBridgeEdges() { return Collections.unmodifiableSet(bridgeEdges); } private void runAnalysis() { - Graph g = graphSupplier.get(); + Graph g = graphSupplier.get(); if (g == null || g.getVertexCount() == 0) { summaryLabel.setText("No graph loaded."); return; diff --git a/Gvisual/src/gvisual/ArticulationPointAnalyzer.java b/Gvisual/src/gvisual/ArticulationPointAnalyzer.java index 7cdbdfb..6e9b8f7 100644 --- a/Gvisual/src/gvisual/ArticulationPointAnalyzer.java +++ b/Gvisual/src/gvisual/ArticulationPointAnalyzer.java @@ -25,7 +25,7 @@ */ public class ArticulationPointAnalyzer { - private final Graph graph; + private final Graph graph; /** * Create a new analyzer for the given graph. @@ -33,7 +33,7 @@ public class ArticulationPointAnalyzer { * @param graph the JUNG graph to analyze (must not be null) * @throws IllegalArgumentException if graph is null */ - public ArticulationPointAnalyzer(Graph graph) { + public ArticulationPointAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -52,7 +52,7 @@ public static class Bridge { 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; @@ -227,7 +227,7 @@ public AnalysisResult analyze() { Map parent = new HashMap(); Set visited = new HashSet(); Set articulationPoints = new LinkedHashSet(); - List bridgeEdges = new ArrayList(); + List bridgeEdges = new ArrayList(); int[] timer = {0}; // Run DFS from each unvisited vertex (handles disconnected graphs) @@ -245,7 +245,7 @@ public AnalysisResult analyze() { for (String ap : articulationPoints) { int degree = graph.degree(ap); Map edgeTypeCounts = new HashMap(); - 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); } @@ -260,7 +260,7 @@ public AnalysisResult analyze() { // Build bridge details with component size estimation List bridges = new ArrayList(); - 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); @@ -284,7 +284,7 @@ private void dfs(String u, Map parent, Set visited, Set articulationPoints, - List bridges, + List bridges, int[] timer) { visited.add(u); disc.put(u, timer[0]); @@ -330,7 +330,7 @@ private void dfs(String u, * Find the edge connecting two vertices. */ private edge findEdge(String u, String v) { - for (edge e : graph.getIncidentEdges(u)) { + 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 @@ -348,7 +348,7 @@ private edge findEdge(String u, String v) { /** * 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 endpoints = graph.getEndpoints(e); if (endpoints != null && endpoints.size() == 2) { Iterator it = endpoints.iterator(); @@ -414,7 +414,7 @@ private Set bfsExcludingEdge(String start, edge excluded) { while (!queue.isEmpty()) { String current = queue.poll(); - for (edge e : graph.getIncidentEdges(current)) { + for (Edge e : graph.getIncidentEdges(current)) { if (e == excluded) continue; Collection endpoints = graph.getEndpoints(e); for (String neighbor : endpoints) { diff --git a/Gvisual/src/gvisual/BipartiteAnalyzer.java b/Gvisual/src/gvisual/BipartiteAnalyzer.java index 4438efd..192c358 100644 --- a/Gvisual/src/gvisual/BipartiteAnalyzer.java +++ b/Gvisual/src/gvisual/BipartiteAnalyzer.java @@ -33,7 +33,7 @@ public class BipartiteAnalyzer { private static final String NIL = "__NIL__"; private static final int INF = Integer.MAX_VALUE; - private final Graph graph; + private final Graph graph; private Map coloring; private boolean bipartite; private boolean computed; @@ -45,7 +45,7 @@ public class BipartiteAnalyzer { * @param graph the JUNG graph to analyze * @throws IllegalArgumentException if graph is null */ - public BipartiteAnalyzer(Graph graph) { + public BipartiteAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } diff --git a/Gvisual/src/gvisual/CentralityPanelController.java b/Gvisual/src/gvisual/CentralityPanelController.java index bcd4f3a..0033374 100644 --- a/Gvisual/src/gvisual/CentralityPanelController.java +++ b/Gvisual/src/gvisual/CentralityPanelController.java @@ -24,12 +24,12 @@ public class CentralityPanelController { private final JButton computeButton; private final JButton clearButton; - private final Supplier> graphSupplier; + private final Supplier> graphSupplier; private boolean active; private final Map results = new HashMap<>(); - public CentralityPanelController(Supplier> graphSupplier) { + public CentralityPanelController(Supplier> graphSupplier) { this.graphSupplier = graphSupplier; Font labelFont = new Font("SansSerif", Font.PLAIN, 12); @@ -106,7 +106,7 @@ public Map getResults() { } private void runAnalysis() { - Graph g = graphSupplier.get(); + Graph g = graphSupplier.get(); if (g == null || g.getVertexCount() == 0) { summaryLabel.setText("No graph loaded."); return; diff --git a/Gvisual/src/gvisual/CentralityRadarExporter.java b/Gvisual/src/gvisual/CentralityRadarExporter.java index fec65d6..b23321d 100644 --- a/Gvisual/src/gvisual/CentralityRadarExporter.java +++ b/Gvisual/src/gvisual/CentralityRadarExporter.java @@ -33,10 +33,10 @@ */ public class CentralityRadarExporter { - private final Graph graph; + private final Graph graph; private String title = "Centrality Radar Chart"; - public CentralityRadarExporter(Graph graph) { + public CentralityRadarExporter(Graph graph) { if (graph == null) throw new IllegalArgumentException("Graph must not be null"); this.graph = graph; } diff --git a/Gvisual/src/gvisual/ChordalGraphAnalyzer.java b/Gvisual/src/gvisual/ChordalGraphAnalyzer.java index c8fc5a6..83405af 100644 --- a/Gvisual/src/gvisual/ChordalGraphAnalyzer.java +++ b/Gvisual/src/gvisual/ChordalGraphAnalyzer.java @@ -192,7 +192,7 @@ public String toTextReport() { * @param graph the graph * @return MCS ordering (last eliminated first) */ - public static List maximumCardinalitySearch(Graph graph) { + public static List maximumCardinalitySearch(Graph graph) { if (graph == null) return Collections.emptyList(); Collection vertices = graph.getVertices(); if (vertices == null || vertices.isEmpty()) return Collections.emptyList(); @@ -247,7 +247,7 @@ public static List maximumCardinalitySearch(Graph graph) { * @param graph the graph * @return ChordalityResult with PEO if chordal, or a chordless cycle if not */ - public static ChordalityResult testChordality(Graph graph) { + public static ChordalityResult testChordality(Graph graph) { if (graph == null || graph.getVertexCount() == 0) { return new ChordalityResult(true, Collections.emptyList(), null); } @@ -349,7 +349,7 @@ private static List findChordlessCycle(Map> adj, * @param graph the graph * @return coloring result */ - public static ColoringResult optimalColoring(Graph graph) { + public static ColoringResult optimalColoring(Graph graph) { if (graph == null || graph.getVertexCount() == 0) { return new ColoringResult(Collections.emptyMap(), 0); } @@ -396,7 +396,7 @@ public static ColoringResult optimalColoring(Graph graph) { * @param graph the graph * @return vertices of a maximum clique */ - public static Set maximumClique(Graph graph) { + public static Set maximumClique(Graph graph) { if (graph == null || graph.getVertexCount() == 0) { return Collections.emptySet(); } @@ -433,7 +433,7 @@ public static Set maximumClique(Graph graph) { return best; } - private static Set findMaxCliqueGreedy(Graph graph) { + private static Set findMaxCliqueGreedy(Graph graph) { Map> adj = GraphUtils.buildAdjacencyMap(graph); // Sort vertices by degree descending List sorted = new ArrayList<>(graph.getVertices()); @@ -467,7 +467,7 @@ private static Set findMaxCliqueGreedy(Graph graph) { * @param graph the graph * @return list of maximal cliques */ - public static List> allMaximalCliques(Graph graph) { + public static List> allMaximalCliques(Graph graph) { if (graph == null || graph.getVertexCount() == 0) { return Collections.emptyList(); } @@ -528,7 +528,7 @@ public static List> allMaximalCliques(Graph graph) { * @param graph the graph * @return list of clique tree nodes with neighbor relationships */ - public static List buildCliqueTree(Graph graph) { + public static List buildCliqueTree(Graph graph) { List> cliques = allMaximalCliques(graph); if (cliques.isEmpty()) return Collections.emptyList(); @@ -597,7 +597,7 @@ private static int intersectionSize(Set a, Set b) { * @param graph the graph * @return fill-in result with list of edges to add */ - public static FillInResult computeFillIn(Graph graph) { + public static FillInResult computeFillIn(Graph graph) { if (graph == null || graph.getVertexCount() == 0) { return new FillInResult(Collections.emptyList()); } @@ -656,7 +656,7 @@ public static FillInResult computeFillIn(Graph graph) { * @param graph the graph * @return list of minimal separators */ - public static List> minimalSeparators(Graph graph) { + public static List> minimalSeparators(Graph graph) { List> cliques = allMaximalCliques(graph); List tree = buildCliqueTree(graph); if (tree.size() <= 1) return Collections.emptyList(); @@ -684,7 +684,7 @@ public static List> minimalSeparators(Graph graph) { * @param graph the graph * @return treewidth, or -1 for empty graph */ - public static int treewidth(Graph graph) { + public static int treewidth(Graph graph) { Set mc = maximumClique(graph); return mc.isEmpty() ? -1 : mc.size() - 1; } @@ -698,7 +698,7 @@ public static int treewidth(Graph graph) { * @param order elimination order * @return list of cliques formed at each elimination step */ - public static List> eliminationCliques(Graph graph, + public static List> eliminationCliques(Graph graph, List order) { if (graph == null || order == null) return Collections.emptyList(); @@ -745,7 +745,7 @@ public static List> eliminationCliques(Graph graph, * @param graph the graph * @return full analysis report */ - public static ChordalReport analyze(Graph graph) { + public static ChordalReport analyze(Graph graph) { int vc = graph != null ? graph.getVertexCount() : 0; int ec = graph != null ? graph.getEdgeCount() : 0; diff --git a/Gvisual/src/gvisual/CircularLayout.java b/Gvisual/src/gvisual/CircularLayout.java index a5d18dc..aab20b9 100644 --- a/Gvisual/src/gvisual/CircularLayout.java +++ b/Gvisual/src/gvisual/CircularLayout.java @@ -39,7 +39,7 @@ *
  • Edge crossing count metric
  • *
  • SVG export with node labels and edges
  • *
  • Layout quality report
  • - *
  • Works with any JUNG {@code Graph}
  • + *
  • Works with any JUNG {@code Graph}
  • * * *

    When to use

    @@ -83,7 +83,7 @@ public enum Ordering { MINIMIZE_CROSSINGS } - private final Graph graph; + private final Graph graph; private final double width; private final double height; private final double padding; @@ -114,7 +114,7 @@ private CircularLayout(Builder builder) { /** Builder for flexible construction. */ public static class Builder { - private final Graph graph; + private final Graph graph; private double width = 800; private double height = 800; private double padding = 50; @@ -123,7 +123,7 @@ public static class Builder { private boolean dualRing = false; private double hubThreshold = 0.9; - public Builder(Graph graph) { + public Builder(Graph graph) { if (graph == null) throw new IllegalArgumentException("Graph must not be null"); this.graph = graph; } @@ -294,7 +294,7 @@ private int countCrossingsForOrder(List order) { } List edgeIndices = new ArrayList<>(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); if (v1 != null && v2 != null && indexMap.containsKey(v1) && indexMap.containsKey(v2)) { @@ -482,7 +482,7 @@ public String toSvg() { width, height)); // Draw edges - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); if (v1 != null && v2 != null && positions.containsKey(v1) && positions.containsKey(v2)) { diff --git a/Gvisual/src/gvisual/CliqueAnalyzer.java b/Gvisual/src/gvisual/CliqueAnalyzer.java index 8962405..3301faf 100644 --- a/Gvisual/src/gvisual/CliqueAnalyzer.java +++ b/Gvisual/src/gvisual/CliqueAnalyzer.java @@ -30,7 +30,7 @@ */ public class CliqueAnalyzer { - private final Graph graph; + private final Graph graph; private Map> neighborCache; private List> cliques; private boolean computed; @@ -44,7 +44,7 @@ public class CliqueAnalyzer { * @param graph the JUNG graph to analyze * @throws IllegalArgumentException if graph is null */ - public CliqueAnalyzer(Graph graph) { + public CliqueAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } diff --git a/Gvisual/src/gvisual/CommunityDetector.java b/Gvisual/src/gvisual/CommunityDetector.java index 88df83c..09a90d3 100644 --- a/Gvisual/src/gvisual/CommunityDetector.java +++ b/Gvisual/src/gvisual/CommunityDetector.java @@ -16,7 +16,7 @@ */ public class CommunityDetector { - private final Graph graph; + private final Graph graph; /** * Creates a new CommunityDetector for the given graph. @@ -24,7 +24,7 @@ public class CommunityDetector { * @param graph the JUNG graph to analyze * @throws IllegalArgumentException if graph is null */ - public CommunityDetector(Graph graph) { + public CommunityDetector(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -175,7 +175,7 @@ public Community getCommunityOf(String node) { * Q = sum_c [ (e_c / m) - (d_c / 2m)^2 ] * where e_c = internal edges, m = total edges, d_c = sum of degrees. */ - public double getModularity(Graph graph) { + public double getModularity(Graph graph) { int m = graph.getEdgeCount(); if (m == 0) return 0.0; @@ -212,7 +212,7 @@ public DetectionResult detect() { int communityId = 0; // Track which edges have been counted globally to avoid double-counting - Set countedEdges = new HashSet(); + Set countedEdges = new HashSet(); // Find connected components via BFS, computing edge metrics inline for (String vertex : graph.getVertices()) { @@ -228,7 +228,7 @@ public DetectionResult detect() { community.members.add(current); nodeToCommunity.put(current, communityId); - for (edge e : graph.getIncidentEdges(current)) { + for (Edge e : graph.getIncidentEdges(current)) { String neighbor = getOtherEnd(e, current); if (neighbor == null) continue; @@ -267,7 +267,7 @@ public DetectionResult detect() { return new DetectionResult(communities, updatedMapping); } - private String getOtherEnd(edge e, String current) { + private String getOtherEnd(Edge e, String current) { return GraphUtils.getOtherEnd(e, current); } } diff --git a/Gvisual/src/gvisual/CommunityEvolutionTracker.java b/Gvisual/src/gvisual/CommunityEvolutionTracker.java index 7c6611a..6614270 100644 --- a/Gvisual/src/gvisual/CommunityEvolutionTracker.java +++ b/Gvisual/src/gvisual/CommunityEvolutionTracker.java @@ -131,16 +131,16 @@ public EvolutionResult track(int windowCount) { throw new IllegalArgumentException("Need at least 2 windows to track evolution"); } - List>> windows = + List>> windows = temporalGraph.generateWindows(windowCount); List snapshots = new ArrayList<>(); List events = new ArrayList<>(); // Detect communities at each window - for (Map.Entry> entry : windows) { + for (Map.Entry> entry : windows) { long timestamp = entry.getKey(); - Graph windowGraph = entry.getValue(); + Graph windowGraph = entry.getValue(); CommunityDetector detector = new CommunityDetector(windowGraph); CommunityDetector.DetectionResult detection = detector.detect(); @@ -178,7 +178,7 @@ public EvolutionResult trackAtTimePoints(List timePoints) { List events = new ArrayList<>(); for (long time : timePoints) { - Graph snapshot = temporalGraph.snapshotAt(time); + Graph snapshot = temporalGraph.snapshotAt(time); CommunityDetector detector = new CommunityDetector(snapshot); CommunityDetector.DetectionResult detection = detector.detect(); @@ -398,7 +398,7 @@ public static class CommunitySnapshot { public CommunitySnapshot(long timestamp, List communities, - Graph graph) { + Graph graph) { this.timestamp = timestamp; this.communities = Collections.unmodifiableList(new ArrayList<>(communities)); this.vertexCount = graph.getVertexCount(); diff --git a/Gvisual/src/gvisual/CommunityPanelController.java b/Gvisual/src/gvisual/CommunityPanelController.java index 84f8c5a..8dda499 100644 --- a/Gvisual/src/gvisual/CommunityPanelController.java +++ b/Gvisual/src/gvisual/CommunityPanelController.java @@ -20,7 +20,7 @@ public class CommunityPanelController { /** Callback for obtaining the graph and requesting repaints. */ public interface GraphHost { - Graph getGraph(); + Graph getGraph(); void onOverlayChanged(); } @@ -107,7 +107,7 @@ private String getDominantLabel(String typeCode) { } private void runDetection() { - Graph g = host.getGraph(); + Graph g = host.getGraph(); if (g == null || g.getVertexCount() == 0) { detailsLabel.setText("No graph loaded."); return; diff --git a/Gvisual/src/gvisual/CsvReportExporter.java b/Gvisual/src/gvisual/CsvReportExporter.java index 8bdf47c..bab8ee9 100644 --- a/Gvisual/src/gvisual/CsvReportExporter.java +++ b/Gvisual/src/gvisual/CsvReportExporter.java @@ -34,8 +34,8 @@ */ public class CsvReportExporter { - private final Graph graph; - private final List allEdges; + private final Graph graph; + private final List allEdges; private String timestamp; /** @@ -45,12 +45,12 @@ public class CsvReportExporter { * @param allEdges all edges (including those possibly filtered out of the graph) * @throws IllegalArgumentException if graph is null */ - public CsvReportExporter(Graph graph, List allEdges) { + public CsvReportExporter(Graph graph, List allEdges) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } this.graph = graph; - this.allEdges = (allEdges != null) ? allEdges : new ArrayList(); + this.allEdges = (allEdges != null) ? allEdges : new ArrayList(); this.timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); } @@ -293,7 +293,7 @@ private Set computeArticulationPoints() { */ private Map computeEdgeTypeCounts() { Map counts = new LinkedHashMap(); - for (edge e : allEdges) { + for (Edge e : allEdges) { if (!graph.containsEdge(e)) continue; String type = e.getType(); int idx = typeIndex(type); diff --git a/Gvisual/src/gvisual/CycleAnalyzer.java b/Gvisual/src/gvisual/CycleAnalyzer.java index 16e3c6a..097053d 100644 --- a/Gvisual/src/gvisual/CycleAnalyzer.java +++ b/Gvisual/src/gvisual/CycleAnalyzer.java @@ -34,7 +34,7 @@ */ public class CycleAnalyzer { - private final Graph graph; + private final Graph graph; private final boolean isDirected; /** @@ -43,7 +43,7 @@ public class CycleAnalyzer { * @param graph the JUNG graph to analyze (directed or undirected) * @throws IllegalArgumentException if graph is null */ - public CycleAnalyzer(Graph graph) { + public CycleAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -72,7 +72,7 @@ public Cycle(List vertices) { public int length() { return vertices.size(); } /** Total weight of all edges in the cycle (0 if no weights). */ - public float totalWeight(Graph graph) { + public float totalWeight(Graph graph) { float w = 0; for (int i = 0; i < vertices.size(); i++) { String from = vertices.get(i); @@ -390,7 +390,7 @@ public List fundamentalCycleBasis() { } // Each non-tree edge defines a fundamental cycle - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); if (v1 == null || v2 == null) continue; diff --git a/Gvisual/src/gvisual/DegreeDistributionAnalyzer.java b/Gvisual/src/gvisual/DegreeDistributionAnalyzer.java index 7ca0e68..4b212c7 100644 --- a/Gvisual/src/gvisual/DegreeDistributionAnalyzer.java +++ b/Gvisual/src/gvisual/DegreeDistributionAnalyzer.java @@ -35,7 +35,7 @@ */ public class DegreeDistributionAnalyzer { - private final Graph graph; + private final Graph graph; private boolean computed; // ── Results ───────────────────────────────────────────────────── @@ -64,7 +64,7 @@ public class DegreeDistributionAnalyzer { * @param graph the JUNG graph to analyse * @throws IllegalArgumentException if graph is null */ - public DegreeDistributionAnalyzer(Graph graph) { + public DegreeDistributionAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -511,7 +511,7 @@ private void fitPowerLaw() { * Pearson correlation coefficient of degree(u), degree(v) over all edges. */ private void computeAssortativity(Map vertexDegree) { - Collection edges = graph.getEdges(); + Collection edges = graph.getEdges(); int m = edges.size(); if (m == 0) { assortativity = 0.0; @@ -522,7 +522,7 @@ private void computeAssortativity(Map vertexDegree) { double sumDegree = 0; double sumDegreeSq = 0; - for (edge e : edges) { + for (Edge e : edges) { Collection endpoints = graph.getIncidentVertices(e); if (endpoints == null || endpoints.size() != 2) continue; Iterator it = endpoints.iterator(); diff --git a/Gvisual/src/gvisual/DominatingSetAnalyzer.java b/Gvisual/src/gvisual/DominatingSetAnalyzer.java index ebefcc3..4cf761b 100644 --- a/Gvisual/src/gvisual/DominatingSetAnalyzer.java +++ b/Gvisual/src/gvisual/DominatingSetAnalyzer.java @@ -40,7 +40,7 @@ */ public class DominatingSetAnalyzer { - private final Graph graph; + private final Graph graph; private final Map> adj; /** @@ -49,7 +49,7 @@ public class DominatingSetAnalyzer { * @param graph the JUNG graph to analyse * @throws IllegalArgumentException if graph is null */ - public DominatingSetAnalyzer(Graph graph) { + public DominatingSetAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } diff --git a/Gvisual/src/gvisual/DotExporter.java b/Gvisual/src/gvisual/DotExporter.java index 8121901..fdcffac 100644 --- a/Gvisual/src/gvisual/DotExporter.java +++ b/Gvisual/src/gvisual/DotExporter.java @@ -37,7 +37,7 @@ */ public class DotExporter { - private final Graph graph; + private final Graph graph; private String graphName = "G"; private String timestamp; private String description; @@ -67,7 +67,7 @@ public class DotExporter { * @param graph the JUNG graph to export * @throws IllegalArgumentException if graph is null */ - public DotExporter(Graph graph) { + public DotExporter(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -171,7 +171,7 @@ public String exportToString() { // Legend as subgraph (if coloring by type) if (colorByEdgeType) { Set usedTypes = new HashSet<>(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { if (e.getType() != null) usedTypes.add(e.getType()); } if (!usedTypes.isEmpty()) { @@ -235,7 +235,7 @@ public String exportToString() { // Compute weight range for edge scaling float minWeight = Float.MAX_VALUE, maxWeight = Float.MIN_VALUE; if (scaleEdgesByWeight) { - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { float w = e.getWeight(); if (w < minWeight) minWeight = w; if (w > maxWeight) maxWeight = w; @@ -245,7 +245,7 @@ public String exportToString() { // Edges sb.append("\n // Edges\n"); Set emittedEdges = new HashSet<>(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); // Deduplicate for undirected graphs diff --git a/Gvisual/src/gvisual/edge.java b/Gvisual/src/gvisual/Edge.java similarity index 97% rename from Gvisual/src/gvisual/edge.java rename to Gvisual/src/gvisual/Edge.java index bb1b6a4..f247a7c 100644 --- a/Gvisual/src/gvisual/edge.java +++ b/Gvisual/src/gvisual/Edge.java @@ -8,7 +8,7 @@ * * @author user */ -public class edge { +public class Edge { private String edgeType; private String vertex1; private String vertex2; @@ -46,7 +46,7 @@ public String getVertex2() /** * Constructor */ - public edge() + public Edge() { } @@ -56,7 +56,7 @@ public edge() * @param vertex1 vertex id * @param vertex2 vertex id */ - public edge(String edgeType,String vertex1,String vertex2) + public Edge(String edgeType,String vertex1,String vertex2) { this.edgeType = edgeType; this.vertex1 = vertex1; diff --git a/Gvisual/src/gvisual/EdgePersistenceAnalyzer.java b/Gvisual/src/gvisual/EdgePersistenceAnalyzer.java index 7f14516..02ba6d5 100644 --- a/Gvisual/src/gvisual/EdgePersistenceAnalyzer.java +++ b/Gvisual/src/gvisual/EdgePersistenceAnalyzer.java @@ -54,18 +54,18 @@ public EdgePersistenceAnalyzer(TemporalGraph temporalGraph, int windowCount) { * @return a map from each edge to its persistence classification */ public Map classify() { - List>> windows = + List>> windows = temporalGraph.generateWindows(windowCount); // Count how many windows each edge appears in Map edgeAppearances = new LinkedHashMap<>(); - for (edge e : temporalGraph.getFullGraph().getEdges()) { + for (Edge e : temporalGraph.getFullGraph().getEdges()) { edgeAppearances.put(e, 0); } - for (Map.Entry> window : windows) { - Graph g = window.getValue(); - for (edge e : g.getEdges()) { + for (Map.Entry> window : windows) { + Graph g = window.getValue(); + for (Edge e : g.getEdges()) { edgeAppearances.merge(e, 1, Integer::sum); } } @@ -108,9 +108,9 @@ public Map summary() { * @param classification one of {@link #PERSISTENT}, {@link #PERIODIC}, {@link #TRANSIENT} * @return set of edges matching the classification */ - public Set getEdgesByClassification(String classification) { + public Set getEdgesByClassification(String classification) { Map classified = classify(); - Set result = new LinkedHashSet<>(); + Set result = new LinkedHashSet<>(); for (Map.Entry entry : classified.entrySet()) { if (classification.equals(entry.getValue())) { result.add(entry.getKey()); diff --git a/Gvisual/src/gvisual/EgoPanelController.java b/Gvisual/src/gvisual/EgoPanelController.java index 37c6fa8..30f17d2 100644 --- a/Gvisual/src/gvisual/EgoPanelController.java +++ b/Gvisual/src/gvisual/EgoPanelController.java @@ -32,21 +32,21 @@ public interface OverlayCallback { private final JLabel summaryLabel; private final JLabel neighborListLabel; - private final Supplier> graphSupplier; + private final Supplier> graphSupplier; private final OverlayCallback callback; // Overlay state — read by GraphRenderers via getters private boolean overlayActive; private String center; private final Set neighbors = new HashSet<>(); - private final Set edges = new HashSet<>(); + private final Set edges = new HashSet<>(); /** * @param graphSupplier supplies the current graph * @param callback invoked after overlay state changes so the host can * call {@code syncRenderers(); vv.repaint();} */ - public EgoPanelController(Supplier> graphSupplier, + public EgoPanelController(Supplier> graphSupplier, OverlayCallback callback) { this.graphSupplier = graphSupplier; this.callback = callback; @@ -100,7 +100,7 @@ public EgoPanelController(Supplier> graphSupplier, public boolean isOverlayActive() { return overlayActive; } public String getCenter() { return center; } public Set getNeighbors() { return Collections.unmodifiableSet(neighbors); } - public Set getEdges() { return Collections.unmodifiableSet(edges); } + public Set getEdges() { return Collections.unmodifiableSet(edges); } // ---- Search logic ---- @@ -110,7 +110,7 @@ private void runSearch() { summaryLabel.setText("Enter a node ID."); return; } - Graph g = graphSupplier.get(); + Graph g = graphSupplier.get(); if (g == null || g.getVertexCount() == 0) { summaryLabel.setText("No graph loaded."); return; @@ -153,7 +153,7 @@ private void runSearch() { neighbors.addAll(nbrs); } - for (edge e : g.getEdges()) { + for (Edge e : g.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); boolean v1InEgo = v1.equals(center) || neighbors.contains(v1); @@ -169,7 +169,7 @@ private void runSearch() { // Count edge types Map typeCounts = new HashMap<>(); - for (edge e : g.getEdges()) { + for (Edge e : g.getEdges()) { if (e.getVertex1().equals(center) || e.getVertex2().equals(center)) { String typeLabel = e.getType(); EdgeType et = EdgeType.fromCode(e.getType()); diff --git a/Gvisual/src/gvisual/EulerianPathAnalyzer.java b/Gvisual/src/gvisual/EulerianPathAnalyzer.java index 6b0e7fd..e3f8221 100644 --- a/Gvisual/src/gvisual/EulerianPathAnalyzer.java +++ b/Gvisual/src/gvisual/EulerianPathAnalyzer.java @@ -26,7 +26,7 @@ */ public class EulerianPathAnalyzer { - private final Graph graph; + private final Graph graph; /** * Create a new analyzer for the given graph. @@ -34,7 +34,7 @@ public class EulerianPathAnalyzer { * @param graph the JUNG graph to analyze (must not be null) * @throws IllegalArgumentException if graph is null */ - public EulerianPathAnalyzer(Graph graph) { + public EulerianPathAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -103,17 +103,17 @@ public int getMinEdgeDuplications() { */ public static class EulerianPathResult { private final List vertices; - private final List edges; + private final List edges; private final boolean isCircuit; - public EulerianPathResult(List vertices, List edges, boolean isCircuit) { + public EulerianPathResult(List vertices, List edges, boolean isCircuit) { this.vertices = Collections.unmodifiableList(new ArrayList(vertices)); - this.edges = Collections.unmodifiableList(new ArrayList(edges)); + this.edges = Collections.unmodifiableList(new ArrayList(edges)); this.isCircuit = isCircuit; } public List getVertices() { return vertices; } - public List getEdges() { return edges; } + public List getEdges() { return edges; } public boolean isCircuit() { return isCircuit; } public int getEdgeCount() { return edges.size(); } } @@ -174,8 +174,8 @@ public EulerianPathResult findEulerianPath() { adj.put(v, new LinkedList()); } - Set allEdges = new HashSet(); - for (edge e : graph.getEdges()) { + Set allEdges = new HashSet(); + for (Edge e : graph.getEdges()) { String v1 = graph.getEndpoints(e).getFirst(); String v2 = graph.getEndpoints(e).getSecond(); EdgeEntry entry1 = new EdgeEntry(v2, e); @@ -206,14 +206,14 @@ public EulerianPathResult findEulerianPath() { if (graph.getVertexCount() > 0) { verts.add(graph.getVertices().iterator().next()); } - return new EulerianPathResult(verts, new ArrayList(), true); + return new EulerianPathResult(verts, new ArrayList(), true); } } // Hierholzer's algorithm Deque stack = new ArrayDeque(); List pathVertices = new ArrayList(); - List pathEdges = new ArrayList(); + List pathEdges = new ArrayList(); stack.push(start); @@ -241,12 +241,12 @@ public EulerianPathResult findEulerianPath() { Collections.reverse(pathVertices); // Reconstruct edges from vertex sequence - List orderedEdges = new ArrayList(); + List orderedEdges = new ArrayList(); for (int i = 0; i < pathVertices.size() - 1; i++) { String v1 = pathVertices.get(i); String v2 = pathVertices.get(i + 1); edge found = null; - for (edge e : allEdges) { + for (Edge e : allEdges) { String e1 = graph.getEndpoints(e).getFirst(); String e2 = graph.getEndpoints(e).getSecond(); if ((e1.equals(v1) && e2.equals(v2)) || (e1.equals(v2) && e2.equals(v1))) { @@ -413,7 +413,7 @@ private int maxFlowBFS(String source, String target) { for (String v : graph.getVertices()) { capacity.put(v, new HashMap()); } - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = graph.getEndpoints(e).getFirst(); String v2 = graph.getEndpoints(e).getSecond(); Integer cur = capacity.get(v1).get(v2); diff --git a/Gvisual/src/gvisual/FeedbackVertexSetAnalyzer.java b/Gvisual/src/gvisual/FeedbackVertexSetAnalyzer.java index a38448f..2378324 100644 --- a/Gvisual/src/gvisual/FeedbackVertexSetAnalyzer.java +++ b/Gvisual/src/gvisual/FeedbackVertexSetAnalyzer.java @@ -36,10 +36,10 @@ */ public class FeedbackVertexSetAnalyzer { - private final Graph graph; + private final Graph graph; private final boolean directed; - public FeedbackVertexSetAnalyzer(Graph graph) { + public FeedbackVertexSetAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -177,11 +177,11 @@ private void backtrack(List candidates, int idx, Set remaining, // ── Feedback Edge Set ───────────────────────────────────────── - public Set feedbackEdgeSet() { + public Set feedbackEdgeSet() { Set vertices = new HashSet<>(graph.getVertices()); if (vertices.isEmpty()) return new HashSet<>(); - Set treeEdges = new HashSet<>(); + Set treeEdges = new HashSet<>(); Set visited = new HashSet<>(); for (String start : vertices) { @@ -190,9 +190,9 @@ public Set feedbackEdgeSet() { queue.add(start); visited.add(start); while (!queue.isEmpty()) { String v = queue.poll(); - Collection incident = graph.getIncidentEdges(v); + Collection incident = graph.getIncidentEdges(v); if (incident == null) continue; - for (edge e : incident) { + for (Edge e : incident) { String other = GraphUtils.getOtherEnd(e, v); if (other != null && !visited.contains(other)) { visited.add(other); treeEdges.add(e); queue.add(other); @@ -201,7 +201,7 @@ public Set feedbackEdgeSet() { } } - Set feedback = new HashSet<>(graph.getEdges()); + Set feedback = new HashSet<>(graph.getEdges()); feedback.removeAll(treeEdges); return feedback; } @@ -318,13 +318,13 @@ public static class FVSReport { public final int vertexCount, edgeCount, cycleRank, lowerBound, upperBound; public final boolean isAcyclic; public final Set greedyFVS, exactFVS; - public final Set feedbackEdgeSet; + public final Set feedbackEdgeSet; public final Map criticality; public final List> cyclePacking; public final double approximationRatio; public FVSReport(int vertexCount, int edgeCount, int cycleRank, boolean isAcyclic, - Set greedyFVS, Set exactFVS, Set feedbackEdgeSet, + Set greedyFVS, Set exactFVS, Set feedbackEdgeSet, int lowerBound, int upperBound, Map criticality, List> cyclePacking, double approximationRatio) { this.vertexCount = vertexCount; this.edgeCount = edgeCount; diff --git a/Gvisual/src/gvisual/ForceDirectedLayout.java b/Gvisual/src/gvisual/ForceDirectedLayout.java index 06bb063..3a6a57f 100644 --- a/Gvisual/src/gvisual/ForceDirectedLayout.java +++ b/Gvisual/src/gvisual/ForceDirectedLayout.java @@ -45,7 +45,7 @@ public class ForceDirectedLayout { /** Barnes-Hut opening angle: lower = more accurate, higher = faster. */ private static final double BH_THETA = 0.8; - private final Graph graph; + private final Graph graph; private final int maxIterations; private final double width; private final double height; @@ -65,7 +65,7 @@ public class ForceDirectedLayout { * @param graph the JUNG graph to lay out * @throws IllegalArgumentException if graph is null */ - public ForceDirectedLayout(Graph graph) { + public ForceDirectedLayout(Graph graph) { this(graph, 300, 800, 600, 0.1, true, 42L); } @@ -82,7 +82,7 @@ public ForceDirectedLayout(Graph graph) { * @param seed random seed for reproducible initial placement * @throws IllegalArgumentException if graph is null or parameters invalid */ - public ForceDirectedLayout(Graph graph, int maxIterations, + public ForceDirectedLayout(Graph graph, int maxIterations, double width, double height, double gravity, boolean useEdgeWeights, long seed) { if (graph == null) { @@ -167,7 +167,7 @@ public ForceDirectedLayout compute() { // Build edge list as index pairs with weights List edgeIndices = new ArrayList(); List edgeWeights = new ArrayList(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { Integer u = indexMap.get(e.getVertex1()); Integer v = indexMap.get(e.getVertex2()); if (u != null && v != null && !u.equals(v)) { @@ -387,7 +387,7 @@ public Map getNormalizedPositions(double vpWidth, */ public int countEdgeCrossings() { ensureComputed(); - List edges = new ArrayList(graph.getEdges()); + List edges = new ArrayList(graph.getEdges()); int m = edges.size(); // Pre-compute endpoint positions and vertex names into arrays @@ -439,7 +439,7 @@ public int countEdgeCrossings() { public double edgeLengthUniformity() { ensureComputed(); List lengths = new ArrayList(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { double[] p1 = positions.get(e.getVertex1()); double[] p2 = positions.get(e.getVertex2()); if (p1 == null || p2 == null) continue; @@ -622,7 +622,7 @@ public String toSVG(int svgWidth, int svgHeight, int nodeRadius) { sb.append(" \n"); // Draw edges - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { double[] p1 = norm.get(e.getVertex1()); double[] p2 = norm.get(e.getVertex2()); if (p1 == null || p2 == null) continue; diff --git a/Gvisual/src/gvisual/GexfExporter.java b/Gvisual/src/gvisual/GexfExporter.java index 5441ad1..a94729d 100644 --- a/Gvisual/src/gvisual/GexfExporter.java +++ b/Gvisual/src/gvisual/GexfExporter.java @@ -43,8 +43,8 @@ public class GexfExporter { private static final String GEXF_NS = "http://gexf.net/1.3"; private static final String VIZ_NS = "http://gexf.net/1.3/viz"; - private final Graph graph; - private final List allEdges; + private final Graph graph; + private final List allEdges; private String creator = "GraphVisual"; private String description = ""; private boolean includeVizData = true; @@ -66,12 +66,12 @@ public class GexfExporter { * @param allEdges all edges, including those filtered from the current view * @throws IllegalArgumentException if graph is null */ - public GexfExporter(Graph graph, List allEdges) { + public GexfExporter(Graph graph, List allEdges) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } this.graph = graph; - this.allEdges = (allEdges != null) ? allEdges : new ArrayList(); + this.allEdges = (allEdges != null) ? allEdges : new ArrayList(); } /** Sets the creator metadata field. */ @@ -182,9 +182,9 @@ public String exportToString() { // Edges — use visible edges from the graph sb.append(" \n"); - Collection edges = graph.getEdges(); + Collection edges = graph.getEdges(); int edgeId = 0; - for (edge e : edges) { + for (Edge e : edges) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); // Only include edges whose vertices are in the graph @@ -239,7 +239,7 @@ public String exportToString() { * Checks whether any edge in the graph carries temporal data. */ private boolean hasTemporalEdges() { - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { if (e.getTimestamp() != null) return true; } return false; diff --git a/Gvisual/src/gvisual/GraphAlgorithmAnimator.java b/Gvisual/src/gvisual/GraphAlgorithmAnimator.java index 76128f8..4564371 100644 --- a/Gvisual/src/gvisual/GraphAlgorithmAnimator.java +++ b/Gvisual/src/gvisual/GraphAlgorithmAnimator.java @@ -38,7 +38,7 @@ */ public class GraphAlgorithmAnimator { - private final Graph graph; + private final Graph graph; private final Map positions; private final int defaultWidth; private final int defaultHeight; @@ -109,7 +109,7 @@ public AnimationFrame(int stepNumber, String algorithmName, * * @param graph the graph to animate */ - public GraphAlgorithmAnimator(Graph graph) { + public GraphAlgorithmAnimator(Graph graph) { this(graph, 800, 600, 18); } @@ -121,7 +121,7 @@ public GraphAlgorithmAnimator(Graph graph) { * @param height SVG viewport height * @param radius node circle radius */ - public GraphAlgorithmAnimator(Graph graph, + public GraphAlgorithmAnimator(Graph graph, int width, int height, int radius) { if (graph == null) throw new IllegalArgumentException("Graph must not be null"); this.graph = graph; @@ -137,7 +137,7 @@ public GraphAlgorithmAnimator(Graph graph, * @param graph the graph * @param positions map of vertex to {x, y} positions */ - public GraphAlgorithmAnimator(Graph graph, + public GraphAlgorithmAnimator(Graph graph, Map positions) { this(graph, positions, 800, 600, 18); } @@ -145,7 +145,7 @@ public GraphAlgorithmAnimator(Graph graph, /** * Create an animator with pre-computed positions and custom dimensions. */ - public GraphAlgorithmAnimator(Graph graph, + public GraphAlgorithmAnimator(Graph graph, Map positions, int width, int height, int radius) { if (graph == null) throw new IllegalArgumentException("Graph must not be null"); @@ -180,7 +180,7 @@ private AnimationState initState() { s.nodeColors.put(v, COLOR_UNVISITED); s.nodeLabels.put(v, v); } - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { s.edgeColors.put(edgeKey(e), COLOR_UNVISITED); } return s; @@ -427,7 +427,7 @@ public List animateKruskal() { Map edgeLabelOverrides = new LinkedHashMap<>(); // Sort edges by weight - List sortedEdges = new ArrayList<>(graph.getEdges()); + List sortedEdges = new ArrayList<>(graph.getEdges()); sortedEdges.sort(Comparator.comparingDouble(edge::getWeight)); // Union-Find @@ -447,7 +447,7 @@ public List animateKruskal() { int treeEdges = 0; double totalWeight = 0; - for (edge e : sortedEdges) { + for (Edge e : sortedEdges) { String u = e.getVertex1(); String v = e.getVertex2(); String ek = edgeKey(e); @@ -614,7 +614,7 @@ public String toSVG(AnimationFrame frame, int width, int height) { int offsetY = 60; // Draw edges - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String ek = edgeKey(e); String color = frame.edgeColors.getOrDefault(ek, COLOR_UNVISITED); double[] p1 = positions.get(e.getVertex1()); @@ -789,7 +789,7 @@ private void validateVertex(String v) { } } - private String edgeKey(edge e) { + private String edgeKey(Edge e) { if (e == null) return ""; String a = e.getVertex1(); String b = e.getVertex2(); @@ -858,7 +858,7 @@ private void union(Map parent, * Compute a simple circular layout for the graph. */ private static Map computeLayout( - Graph graph, int width, int height, int radius) { + Graph graph, int width, int height, int radius) { Map pos = new LinkedHashMap<>(); List vertices = new ArrayList<>(graph.getVertices()); Collections.sort(vertices); diff --git a/Gvisual/src/gvisual/GraphAnomalyDetector.java b/Gvisual/src/gvisual/GraphAnomalyDetector.java index f0790ef..799c58d 100644 --- a/Gvisual/src/gvisual/GraphAnomalyDetector.java +++ b/Gvisual/src/gvisual/GraphAnomalyDetector.java @@ -49,7 +49,7 @@ public class GraphAnomalyDetector { /** Number of metric dimensions. */ private static final int NUM_DIMENSIONS = 4; - private final Graph graph; + private final Graph graph; private List results; private boolean analyzed; @@ -71,7 +71,7 @@ public class GraphAnomalyDetector { * @param graph the JUNG graph to analyze (must not be null) * @throws IllegalArgumentException if graph is null */ - public GraphAnomalyDetector(Graph graph) { + public GraphAnomalyDetector(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -427,12 +427,12 @@ private double computeClusteringCoeff(String v) { *

    Normalized to [0, 1] by dividing by log(numCategories).

    */ private double computeEdgeDiversity(String v) { - Collection edges = graph.getIncidentEdges(v); + Collection edges = graph.getIncidentEdges(v); if (edges == null || edges.isEmpty()) return 0.0; Map typeCounts = new HashMap(); int total = 0; - for (edge e : edges) { + for (Edge e : edges) { String type = e.getType(); if (type == null) type = "unknown"; Integer count = typeCounts.get(type); diff --git a/Gvisual/src/gvisual/GraphAsciiRenderer.java b/Gvisual/src/gvisual/GraphAsciiRenderer.java index 644ecfc..cec6a7d 100644 --- a/Gvisual/src/gvisual/GraphAsciiRenderer.java +++ b/Gvisual/src/gvisual/GraphAsciiRenderer.java @@ -39,7 +39,7 @@ */ public class GraphAsciiRenderer { - private final Graph graph; + private final Graph graph; private int width = 100; private int height = 35; private boolean unicode = false; @@ -74,7 +74,7 @@ public class GraphAsciiRenderer { * @param graph the JUNG graph to render * @throws IllegalArgumentException if graph is null */ - public GraphAsciiRenderer(Graph graph) { + public GraphAsciiRenderer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -161,7 +161,7 @@ public String render() { for (char[] row : grid) Arrays.fill(row, SPACE); // Draw edges - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); if (v1 == null || v2 == null) continue; @@ -259,7 +259,7 @@ public String render() { // Edge type distribution Map typeCounts = new TreeMap<>(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String type = e.getType() != null ? e.getType() : "unknown"; typeCounts.merge(type, 1, Integer::sum); } @@ -388,7 +388,7 @@ private void computeLayout() { // Build adjacency for quick lookup Set edgeSet = new HashSet<>(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { if (e.getVertex1() != null && e.getVertex2() != null) { edgeSet.add(e.getVertex1() + "|" + e.getVertex2()); edgeSet.add(e.getVertex2() + "|" + e.getVertex1()); @@ -424,7 +424,7 @@ private void computeLayout() { } // Attractive forces along edges - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); if (v1 == null || v2 == null) continue; diff --git a/Gvisual/src/gvisual/GraphBenchmarkSuite.java b/Gvisual/src/gvisual/GraphBenchmarkSuite.java index 030609d..7f01d93 100644 --- a/Gvisual/src/gvisual/GraphBenchmarkSuite.java +++ b/Gvisual/src/gvisual/GraphBenchmarkSuite.java @@ -14,13 +14,13 @@ public class GraphBenchmarkSuite { public static class BenchmarkGraph { private final String name; private final String description; - private final Graph graph; + private final Graph graph; private final int expectedNodes; private final int expectedEdges; private final Map properties; public BenchmarkGraph(String name, String description, - Graph graph, + Graph graph, int expectedNodes, int expectedEdges, Map properties) { this.name = name; @@ -33,7 +33,7 @@ public BenchmarkGraph(String name, String description, public String getName() { return name; } public String getDescription() { return description; } - public Graph getGraph() { return graph; } + public Graph getGraph() { return graph; } public int getExpectedNodes() { return expectedNodes; } public int getExpectedEdges() { return expectedEdges; } public Map getProperties() { return properties; } @@ -59,10 +59,10 @@ public String getSummary() { } } - private static void addEdge(Graph g, String v1, String v2) { + private static void addEdge(Graph g, String v1, String v2) { if (!g.containsVertex(v1)) g.addVertex(v1); if (!g.containsVertex(v2)) g.addVertex(v2); - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setLabel(v1 + "-" + v2); g.addEdge(e, v1, v2); } @@ -74,7 +74,7 @@ private static Map props(String... pairs) { } public BenchmarkGraph zacharyKarateClub() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); int[][] edges = { {1,2},{1,3},{1,4},{1,5},{1,6},{1,7},{1,8},{1,9},{1,11},{1,12}, {1,13},{1,14},{1,18},{1,20},{1,22},{1,32}, @@ -95,7 +95,7 @@ public BenchmarkGraph zacharyKarateClub() { } public BenchmarkGraph petersenGraph() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); int[][] edges = {{0,1},{1,2},{2,3},{3,4},{4,0},{5,7},{7,9},{9,6},{6,8},{8,5},{0,5},{1,6},{2,7},{3,8},{4,9}}; for (int[] p : edges) addEdge(g, String.valueOf(p[0]), String.valueOf(p[1])); return new BenchmarkGraph("Petersen Graph", @@ -104,7 +104,7 @@ public BenchmarkGraph petersenGraph() { } public BenchmarkGraph florentineFamilies() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); String[][] edges = { {"Medici","Barbadori"},{"Medici","Ridolfi"},{"Medici","Tornabuoni"}, {"Medici","Albizzi"},{"Medici","Salviati"},{"Medici","Acciaiuoli"}, @@ -122,7 +122,7 @@ public BenchmarkGraph florentineFamilies() { } public BenchmarkGraph cubeGraph() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); int[][] edges = {{0,1},{0,2},{0,4},{1,3},{1,5},{2,3},{2,6},{3,7},{4,5},{4,6},{5,7},{6,7}}; for (int[] p : edges) { String v1 = String.format("%03d", Integer.parseInt(Integer.toBinaryString(p[0]))); @@ -135,7 +135,7 @@ public BenchmarkGraph cubeGraph() { } public BenchmarkGraph dodecahedron() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); int[][] edges = { {1,2},{2,3},{3,4},{4,5},{5,1},{1,6},{2,7},{3,8},{4,9},{5,10}, {6,11},{6,15},{7,11},{7,12},{8,12},{8,13},{9,13},{9,14},{10,14},{10,15}, @@ -148,7 +148,7 @@ public BenchmarkGraph dodecahedron() { } public BenchmarkGraph tutteGraph() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); int[][] edges = { {1,2},{1,4},{1,26}, {2,3},{2,5},{3,4},{3,8},{4,29}, @@ -171,7 +171,7 @@ public BenchmarkGraph tutteGraph() { public BenchmarkGraph friendshipGraph(int n) { if (n < 1) throw new IllegalArgumentException("n must be >= 1"); - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); g.addVertex("0"); for (int i = 0; i < n; i++) { String a = String.valueOf(2 * i + 1), b = String.valueOf(2 * i + 2); diff --git a/Gvisual/src/gvisual/GraphCentralityCorrelator.java b/Gvisual/src/gvisual/GraphCentralityCorrelator.java index 23757e2..4d9cc35 100644 --- a/Gvisual/src/gvisual/GraphCentralityCorrelator.java +++ b/Gvisual/src/gvisual/GraphCentralityCorrelator.java @@ -17,7 +17,7 @@ */ public class GraphCentralityCorrelator { - private final Graph graph; + private final Graph graph; private final NodeCentralityAnalyzer centralityAnalyzer; private boolean computed; @@ -158,7 +158,7 @@ public int hashCode() { * @param graph the JUNG graph to analyze * @throws IllegalArgumentException if graph is null */ - public GraphCentralityCorrelator(Graph graph) { + public GraphCentralityCorrelator(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } diff --git a/Gvisual/src/gvisual/GraphClusterQualityAnalyzer.java b/Gvisual/src/gvisual/GraphClusterQualityAnalyzer.java index 235dc0c..9c52313 100644 --- a/Gvisual/src/gvisual/GraphClusterQualityAnalyzer.java +++ b/Gvisual/src/gvisual/GraphClusterQualityAnalyzer.java @@ -39,7 +39,7 @@ * *

    Usage

    *
    {@code
    - * Graph g = ...;
    + * Graph g = ...;
      * Map clustering = new HashMap<>();
      * clustering.put("A", 0);
      * clustering.put("B", 0);
    @@ -55,7 +55,7 @@
      */
     public class GraphClusterQualityAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /**
          * Creates a new cluster quality analyzer for the given graph.
    @@ -63,7 +63,7 @@ public class GraphClusterQualityAnalyzer {
          * @param graph the JUNG graph whose clustering will be evaluated
          * @throws IllegalArgumentException if graph is null
          */
    -    public GraphClusterQualityAnalyzer(Graph graph) {
    +    public GraphClusterQualityAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -264,7 +264,7 @@ public QualityReport evaluate(Map clustering) {
             // Count intra-cluster and inter-cluster edges
             int intraEdges = 0;
             int interEdges = 0;
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String v1 = e.getVertex1();
                 String v2 = e.getVertex2();
                 Integer c1 = clustering.get(v1);
    @@ -307,10 +307,10 @@ public QualityReport evaluate(Map clustering) {
                 int totalDegree = 0;
     
                 for (String node : members) {
    -                Collection incidents = graph.getIncidentEdges(node);
    +                Collection incidents = graph.getIncidentEdges(node);
                     if (incidents == null) continue;
                     totalDegree += incidents.size();
    -                for (edge e : incidents) {
    +                for (Edge e : incidents) {
                         String neighbor = getOtherEnd(e, node);
                         Integer neighborCluster = clustering.get(neighbor);
                         if (neighborCluster != null && neighborCluster.equals(cid)) {
    @@ -540,10 +540,10 @@ private double computeModularity(
                 int clusterDegreeSum = 0;
     
                 for (String node : members) {
    -                Collection incidents = graph.getIncidentEdges(node);
    +                Collection incidents = graph.getIncidentEdges(node);
                     if (incidents == null) continue;
                     clusterDegreeSum += incidents.size();
    -                for (edge e : incidents) {
    +                for (Edge e : incidents) {
                         String neighbor = getOtherEnd(e, node);
                         if (members.contains(neighbor)) {
                             clusterIntra++;
    @@ -584,7 +584,7 @@ private Map> invertClustering(Map clusteri
             return result;
         }
     
    -    private String getOtherEnd(edge e, String node) {
    +    private String getOtherEnd(Edge e, String node) {
             return e.getVertex1().equals(node) ? e.getVertex2() : e.getVertex1();
         }
     
    diff --git a/Gvisual/src/gvisual/GraphColoringAnalyzer.java b/Gvisual/src/gvisual/GraphColoringAnalyzer.java
    index 5747dbd..71879f0 100644
    --- a/Gvisual/src/gvisual/GraphColoringAnalyzer.java
    +++ b/Gvisual/src/gvisual/GraphColoringAnalyzer.java
    @@ -43,7 +43,7 @@ public enum VertexOrdering {
             DSATUR
         }
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /**
          * Creates a new GraphColoringAnalyzer for the given graph.
    @@ -51,7 +51,7 @@ public enum VertexOrdering {
          * @param graph the JUNG graph to color
          * @throws IllegalArgumentException if graph is null
          */
    -    public GraphColoringAnalyzer(Graph graph) {
    +    public GraphColoringAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -395,7 +395,7 @@ public List findConflicts(Map assignment) {
                 throw new IllegalArgumentException("Assignment must not be null");
             }
             List conflicts = new ArrayList<>();
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String v1 = graph.getEndpoints(e).getFirst();
                 String v2 = graph.getEndpoints(e).getSecond();
                 Integer c1 = assignment.get(v1);
    @@ -674,7 +674,7 @@ private Map> buildColorClasses(
         }
     
         private boolean validate(Map assignment) {
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String v1 = graph.getEndpoints(e).getFirst();
                 String v2 = graph.getEndpoints(e).getSecond();
                 Integer c1 = assignment.get(v1);
    diff --git a/Gvisual/src/gvisual/GraphCompressor.java b/Gvisual/src/gvisual/GraphCompressor.java
    index 352a646..7483a0f 100644
    --- a/Gvisual/src/gvisual/GraphCompressor.java
    +++ b/Gvisual/src/gvisual/GraphCompressor.java
    @@ -49,7 +49,7 @@
      */
     public class GraphCompressor {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /**
          * Creates a compressor for the given graph.
    @@ -57,7 +57,7 @@ public class GraphCompressor {
          * @param graph the graph to compress (must not be null)
          * @throws IllegalArgumentException if graph is null
          */
    -    public GraphCompressor(Graph graph) {
    +    public GraphCompressor(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -289,7 +289,7 @@ public String compressibilityReport() {
         // ── Quotient Graph Builder ──────────────────────────────────────
     
         private CompressionResult buildQuotientGraph(List> groups, String strategy) {
    -        Graph quotient = new UndirectedSparseGraph<>();
    +        Graph quotient = new UndirectedSparseGraph<>();
             Map> supernodeMembers = new LinkedHashMap<>();
             Map nodeToSupernode = new HashMap<>();
     
    @@ -314,7 +314,7 @@ private CompressionResult buildQuotientGraph(List> groups, String s
             int edgeCounter = 0;
             Map superEdgeInfos = new HashMap<>();
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String v1 = graph.getEndpoints(e).getFirst();
                 String v2 = graph.getEndpoints(e).getSecond();
                 String s1 = nodeToSupernode.get(v1);
    @@ -328,7 +328,7 @@ private CompressionResult buildQuotientGraph(List> groups, String s
                     info = new SuperEdgeInfo();
                     superEdgeInfos.put(edgeKey, info);
     
    -                edge superEdge = new edge("super", s1, s2);
    +                edge superEdge = new Edge("super", s1, s2);
                     superEdge.setLabel("compressed");
                     quotient.addEdge(superEdge, s1, s2);
                     info.edge = superEdge;
    @@ -380,14 +380,14 @@ private static class SuperEdgeInfo {
          * graph, supernode membership mappings, and compression statistics.
          */
         public static class CompressionResult {
    -        private final Graph original;
    -        private final Graph compressed;
    +        private final Graph original;
    +        private final Graph compressed;
             private final Map> supernodeMembers;
             private final Map nodeToSupernode;
             private final String strategy;
     
    -        CompressionResult(Graph original,
    -                          Graph compressed,
    +        CompressionResult(Graph original,
    +                          Graph compressed,
                               Map> supernodeMembers,
                               Map nodeToSupernode,
                               String strategy) {
    @@ -399,7 +399,7 @@ public static class CompressionResult {
             }
     
             /** Returns the compressed quotient graph. */
    -        public Graph getCompressedGraph() { return compressed; }
    +        public Graph getCompressedGraph() { return compressed; }
     
             /** Returns a map from supernode ID to its member node IDs. */
             public Map> getSupernodeMembers() { return supernodeMembers; }
    diff --git a/Gvisual/src/gvisual/GraphDiameterAnalyzer.java b/Gvisual/src/gvisual/GraphDiameterAnalyzer.java
    index aa28883..65473dd 100644
    --- a/Gvisual/src/gvisual/GraphDiameterAnalyzer.java
    +++ b/Gvisual/src/gvisual/GraphDiameterAnalyzer.java
    @@ -23,7 +23,7 @@
      */
     public class GraphDiameterAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private Map eccentricities;
         private int diameter;
         private int radius;
    @@ -38,7 +38,7 @@ public class GraphDiameterAnalyzer {
          * @param graph the JUNG graph to analyze
          * @throws IllegalArgumentException if graph is null
          */
    -    public GraphDiameterAnalyzer(Graph graph) {
    +    public GraphDiameterAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -216,7 +216,7 @@ private Set findLargestComponent() {
             return GraphUtils.findLargestComponent(graph);
         }
     
    -    private String getOtherEnd(edge e, String current) {
    +    private String getOtherEnd(Edge e, String current) {
             return GraphUtils.getOtherEnd(e, current);
         }
     
    diff --git a/Gvisual/src/gvisual/GraphDiffAnalyzer.java b/Gvisual/src/gvisual/GraphDiffAnalyzer.java
    index 14314e9..f5f9e64 100644
    --- a/Gvisual/src/gvisual/GraphDiffAnalyzer.java
    +++ b/Gvisual/src/gvisual/GraphDiffAnalyzer.java
    @@ -28,8 +28,8 @@
      */
     public class GraphDiffAnalyzer {
     
    -    private final Graph graphA;
    -    private final Graph graphB;
    +    private final Graph graphA;
    +    private final Graph graphB;
     
         /**
          * Create a diff analyzer comparing graphA (baseline) to graphB (target).
    @@ -38,7 +38,7 @@ public class GraphDiffAnalyzer {
          * @param graphB the target graph to compare against
          * @throws IllegalArgumentException if either graph is null
          */
    -    public GraphDiffAnalyzer(Graph graphA, Graph graphB) {
    +    public GraphDiffAnalyzer(Graph graphA, Graph graphB) {
             if (graphA == null || graphB == null) {
                 throw new IllegalArgumentException("Both graphs must not be null");
             }
    @@ -285,9 +285,9 @@ public int computeEditDistance() {
     
         // ── Helpers ─────────────────────────────────────────────────
     
    -    private Set extractEdges(Graph g) {
    +    private Set extractEdges(Graph g) {
             Set edges = new HashSet<>();
    -        for (edge e : g.getEdges()) {
    +        for (Edge e : g.getEdges()) {
                 Collection endpoints = g.getEndpoints(e);
                 if (endpoints != null && endpoints.size() == 2) {
                     Iterator it = endpoints.iterator();
    diff --git a/Gvisual/src/gvisual/GraphDiffHtmlExporter.java b/Gvisual/src/gvisual/GraphDiffHtmlExporter.java
    index e99570a..929e956 100644
    --- a/Gvisual/src/gvisual/GraphDiffHtmlExporter.java
    +++ b/Gvisual/src/gvisual/GraphDiffHtmlExporter.java
    @@ -34,8 +34,8 @@
      */
     public class GraphDiffHtmlExporter {
     
    -    private final Graph graphA;
    -    private final Graph graphB;
    +    private final Graph graphA;
    +    private final Graph graphB;
         private String title = "Graph Diff Visualization";
         private String labelA = "Graph A";
         private String labelB = "Graph B";
    @@ -43,7 +43,7 @@ public class GraphDiffHtmlExporter {
         private int width = 1200;
         private int height = 700;
     
    -    public GraphDiffHtmlExporter(Graph graphA, Graph graphB) {
    +    public GraphDiffHtmlExporter(Graph graphA, Graph graphB) {
             if (graphA == null || graphB == null) {
                 throw new IllegalArgumentException("Both graphs must not be null");
             }
    diff --git a/Gvisual/src/gvisual/GraphDistanceDistribution.java b/Gvisual/src/gvisual/GraphDistanceDistribution.java
    index 2c5d875..d897c41 100644
    --- a/Gvisual/src/gvisual/GraphDistanceDistribution.java
    +++ b/Gvisual/src/gvisual/GraphDistanceDistribution.java
    @@ -28,7 +28,7 @@
      */
     public class GraphDistanceDistribution {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private Map> distanceMatrix;
         private boolean computed;
     
    @@ -38,7 +38,7 @@ public class GraphDistanceDistribution {
          * @param graph the JUNG graph to analyse
          * @throws IllegalArgumentException if graph is null
          */
    -    public GraphDistanceDistribution(Graph graph) {
    +    public GraphDistanceDistribution(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    diff --git a/Gvisual/src/gvisual/GraphEntropyAnalyzer.java b/Gvisual/src/gvisual/GraphEntropyAnalyzer.java
    index 7104449..039418e 100644
    --- a/Gvisual/src/gvisual/GraphEntropyAnalyzer.java
    +++ b/Gvisual/src/gvisual/GraphEntropyAnalyzer.java
    @@ -53,7 +53,7 @@ public class GraphEntropyAnalyzer {
         private static final double EPSILON = 1e-12;
         private static final int JACOBI_MAX_SWEEPS = 100;
     
    -    private final Graph graph;
    +    private final Graph graph;
         private boolean computed;
     
         // ── Results ─────────────────────────────────────────────────────
    @@ -68,7 +68,7 @@ public class GraphEntropyAnalyzer {
         private double avgNeighbourhoodEntropy;
         private String complexityClass;
     
    -    public GraphEntropyAnalyzer(Graph graph) {
    +    public GraphEntropyAnalyzer(Graph graph) {
             this.graph = Objects.requireNonNull(graph, "graph must not be null");
             this.computed = false;
             this.neighbourhoodEntropy = new LinkedHashMap<>();
    @@ -251,7 +251,7 @@ private void computeEdgeTypeEntropy() {
             if (m == 0) { edgeTypeEntropy = 0; return; }
     
             Map freq = new HashMap<>();
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String type = e.getType();
                 if (type == null) type = "unknown";
                 Integer old = freq.get(type);
    @@ -479,7 +479,7 @@ private double[][] buildLaplacian() {
             for (int i = 0; i < n; i++) idx.put(vList.get(i), i);
     
             double[][] L = new double[n][n];
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String v1 = graph.getEndpoints(e).getFirst();
                 String v2 = graph.getEndpoints(e).getSecond();
                 int i = idx.get(v1);
    diff --git a/Gvisual/src/gvisual/GraphFileParser.java b/Gvisual/src/gvisual/GraphFileParser.java
    index 3138641..831f974 100644
    --- a/Gvisual/src/gvisual/GraphFileParser.java
    +++ b/Gvisual/src/gvisual/GraphFileParser.java
    @@ -42,13 +42,13 @@ public class GraphFileParser {
          * lists, and the set of all vertices found.
          */
         public static class ParseResult {
    -        private final Graph graph;
    -        private final Map> edgesByType;
    +        private final Graph graph;
    +        private final Map> edgesByType;
             private final Set vertices;
             private final int skippedLines;
     
    -        ParseResult(Graph graph,
    -                    Map> edgesByType,
    +        ParseResult(Graph graph,
    +                    Map> edgesByType,
                         Set vertices,
                         int skippedLines) {
                 this.graph = graph;
    @@ -58,13 +58,13 @@ public static class ParseResult {
             }
     
             /** The parsed JUNG graph (undirected, sparse). */
    -        public Graph getGraph() { return graph; }
    +        public Graph getGraph() { return graph; }
     
             /** Edges grouped by {@link EdgeType}. */
    -        public Map> getEdgesByType() { return edgesByType; }
    +        public Map> getEdgesByType() { return edgesByType; }
     
             /** Convenience accessor for a single edge type's list (never null). */
    -        public List getEdges(EdgeType type) {
    +        public List getEdges(EdgeType type) {
                 return edgesByType.getOrDefault(type, Collections.emptyList());
             }
     
    @@ -88,8 +88,8 @@ public List getEdges(EdgeType type) {
         public static ParseResult parse(String filePath, Predicate visibleFilter)
                 throws IOException {
     
    -        Graph g = new UndirectedSparseGraph<>();
    -        Map> edgesByType = new EnumMap<>(EdgeType.class);
    +        Graph g = new UndirectedSparseGraph<>();
    +        Map> edgesByType = new EnumMap<>(EdgeType.class);
             for (EdgeType t : EdgeType.values()) {
                 edgesByType.put(t, new ArrayList<>());
             }
    @@ -150,13 +150,13 @@ public static ParseResult parse(String filePath, Predicate visibleFilter
                             continue;
                         }
     
    -                    edge curEdge = new edge(parts[0], parts[1], parts[2]);
    +                    edge curEdge = new Edge(parts[0], parts[1], parts[2]);
                         curEdge.setWeight(weight);
     
                         // Classify by type
                         EdgeType edgeType = EdgeType.fromCode(parts[0]);
                         if (edgeType != null) {
    -                        List typeList = edgesByType.get(edgeType);
    +                        List typeList = edgesByType.get(edgeType);
                             // Set label on first edge of each type for the legend
                             if (typeList.stream().noneMatch(e -> e.getLabel() != null)) {
                                 curEdge.setLabel(edgeType.getDisplayLabel());
    diff --git a/Gvisual/src/gvisual/GraphGenerator.java b/Gvisual/src/gvisual/GraphGenerator.java
    index 8832448..adf1786 100644
    --- a/Gvisual/src/gvisual/GraphGenerator.java
    +++ b/Gvisual/src/gvisual/GraphGenerator.java
    @@ -10,7 +10,7 @@
      * 

    Useful for testing analysis algorithms, benchmarking performance, * exploring graph properties, and creating example networks for * demonstrations. All generated graphs use the same JUNG graph type - * ({@code UndirectedSparseGraph}) as the rest of the + * ({@code UndirectedSparseGraph}) as the rest of the * application.

    * *

    Supported topologies:

    @@ -33,7 +33,7 @@ * * // Create a scale-free network with 100 nodes * GraphGenerator.GeneratedGraph sf = gen.scaleFreeBa(100, 3); - * Graph graph = sf.getGraph(); + * Graph graph = sf.getGraph(); * * // Create a small-world network * GraphGenerator.GeneratedGraph sw = gen.smallWorldWs(50, 4, 0.1); @@ -70,11 +70,11 @@ public GraphGenerator(long seed) { * Holds a generated graph along with metadata about how it was created. */ public static class GeneratedGraph { - private final Graph graph; + private final Graph graph; private final String topology; private final Map parameters; - GeneratedGraph(Graph graph, String topology, + GeneratedGraph(Graph graph, String topology, Map parameters) { this.graph = graph; this.topology = topology; @@ -82,7 +82,7 @@ public static class GeneratedGraph { } /** The generated JUNG graph. */ - public Graph getGraph() { return graph; } + public Graph getGraph() { return graph; } /** Name of the topology used. */ public String getTopology() { return topology; } @@ -145,19 +145,19 @@ private String nodeName(int i) { } private edge createEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setLabel("gen_" + (edgeCounter++)); e.setWeight(1.0f); return e; } - private void addNodes(Graph graph, int n) { + private void addNodes(Graph graph, int n) { for (int i = 0; i < n; i++) { graph.addVertex(nodeName(i)); } } - private void addEdgeIfAbsent(Graph graph, String v1, String v2) { + private void addEdgeIfAbsent(Graph graph, String v1, String v2) { if (v1.equals(v2)) return; if (graph.findEdge(v1, v2) == null) { graph.addEdge(createEdge(v1, v2), v1, v2); @@ -179,7 +179,7 @@ private void addEdgeIfAbsent(Graph graph, String v1, String v2) { */ public GeneratedGraph complete(int n) { if (n < 1) throw new IllegalArgumentException("n must be >= 1"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addNodes(g, n); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { @@ -204,7 +204,7 @@ public GeneratedGraph complete(int n) { */ public GeneratedGraph ring(int n) { if (n < 3) throw new IllegalArgumentException("Ring requires n >= 3"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addNodes(g, n); for (int i = 0; i < n; i++) { int next = (i + 1) % n; @@ -228,7 +228,7 @@ public GeneratedGraph ring(int n) { */ public GeneratedGraph star(int n) { if (n < 2) throw new IllegalArgumentException("Star requires n >= 2"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addNodes(g, n); String hub = nodeName(0); for (int i = 1; i < n; i++) { @@ -254,7 +254,7 @@ public GeneratedGraph star(int n) { */ public GeneratedGraph grid(int rows, int cols) { if (rows < 1 || cols < 1) throw new IllegalArgumentException("rows and cols must be >= 1"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); int n = rows * cols; addNodes(g, n); for (int r = 0; r < rows; r++) { @@ -290,7 +290,7 @@ public GeneratedGraph grid(int rows, int cols) { */ public GeneratedGraph path(int n) { if (n < 2) throw new IllegalArgumentException("Path requires n >= 2"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addNodes(g, n); for (int i = 0; i < n - 1; i++) { g.addEdge(createEdge(nodeName(i), nodeName(i + 1)), @@ -317,7 +317,7 @@ public GeneratedGraph path(int n) { public GeneratedGraph tree(int branchingFactor, int depth) { if (branchingFactor < 1) throw new IllegalArgumentException("branchingFactor must be >= 1"); if (depth < 0) throw new IllegalArgumentException("depth must be >= 0"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); int nodeId = 0; g.addVertex(nodeName(nodeId)); @@ -362,7 +362,7 @@ public GeneratedGraph tree(int branchingFactor, int depth) { public GeneratedGraph randomErdosRenyi(int n, double p) { if (n < 1) throw new IllegalArgumentException("n must be >= 1"); if (p < 0.0 || p > 1.0) throw new IllegalArgumentException("p must be in [0, 1]"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addNodes(g, n); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { @@ -398,7 +398,7 @@ public GeneratedGraph randomErdosRenyi(int n, double p) { public GeneratedGraph scaleFreeBa(int n, int m) { if (m < 1) throw new IllegalArgumentException("m must be >= 1"); if (n <= m) throw new IllegalArgumentException("n must be > m"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); // Start with a complete graph of m+1 nodes for (int i = 0; i <= m; i++) { @@ -471,7 +471,7 @@ public GeneratedGraph smallWorldWs(int n, int k, double beta) { if (k >= n) throw new IllegalArgumentException("k must be < n"); if (beta < 0.0 || beta > 1.0) throw new IllegalArgumentException("beta must be in [0, 1]"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addNodes(g, n); // Create ring lattice @@ -535,7 +535,7 @@ public GeneratedGraph bipartite(int groupASize, int groupBSize, double p) { if (p < 0.0 || p > 1.0) throw new IllegalArgumentException("p must be in [0, 1]"); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); int total = groupASize + groupBSize; addNodes(g, total); diff --git a/Gvisual/src/gvisual/GraphIsomorphismAnalyzer.java b/Gvisual/src/gvisual/GraphIsomorphismAnalyzer.java index 9e40fbb..6dcccd8 100644 --- a/Gvisual/src/gvisual/GraphIsomorphismAnalyzer.java +++ b/Gvisual/src/gvisual/GraphIsomorphismAnalyzer.java @@ -26,8 +26,8 @@ */ public class GraphIsomorphismAnalyzer { - private final Graph graph1; - private final Graph graph2; + private final Graph graph1; + private final Graph graph2; /** * Create a new isomorphism analyzer for two graphs. @@ -36,8 +36,8 @@ public class GraphIsomorphismAnalyzer { * @param graph2 the second graph (must not be null) * @throws IllegalArgumentException if either graph is null */ - public GraphIsomorphismAnalyzer(Graph graph1, - Graph graph2) { + public GraphIsomorphismAnalyzer(Graph graph1, + Graph graph2) { if (graph1 == null || graph2 == null) { throw new IllegalArgumentException("Both graphs must not be null"); } @@ -193,7 +193,7 @@ public boolean areIsomorphic() { /** * Compute the sorted degree sequence of a graph. */ - private List getSortedDegreeSequence(Graph g, + private List getSortedDegreeSequence(Graph g, List vertices) { List degrees = new ArrayList(vertices.size()); for (String v : vertices) { @@ -209,7 +209,7 @@ private List getSortedDegreeSequence(Graph g, /** * Group vertices by their degree. */ - private Map> groupByDegree(Graph g, + private Map> groupByDegree(Graph g, List vertices) { Map> groups = new HashMap>(); diff --git a/Gvisual/src/gvisual/GraphLayoutComparer.java b/Gvisual/src/gvisual/GraphLayoutComparer.java index 5bd0377..8752db6 100644 --- a/Gvisual/src/gvisual/GraphLayoutComparer.java +++ b/Gvisual/src/gvisual/GraphLayoutComparer.java @@ -36,10 +36,10 @@ */ public class GraphLayoutComparer { - private final Graph graph; + private final Graph graph; private String title = "Graph Layout Comparison"; - public GraphLayoutComparer(Graph graph) { + public GraphLayoutComparer(Graph graph) { this.graph = Objects.requireNonNull(graph, "graph must not be null"); } @@ -64,7 +64,7 @@ public void export(File file) throws IOException { public String exportToString() { StringBuilder sb = new StringBuilder(16384); Collection vertices = graph.getVertices(); - Collection edges = graph.getEdges(); + Collection edges = graph.getEdges(); // Build JSON data StringBuilder nodeJson = new StringBuilder("["); @@ -82,7 +82,7 @@ public String exportToString() { StringBuilder linkJson = new StringBuilder("["); boolean first = true; - for (edge e : edges) { + for (Edge e : edges) { String v1 = e.getVertex1() != null ? e.getVertex1() : graph.getEndpoints(e).getFirst().toString(); String v2 = e.getVertex2() != null ? e.getVertex2() : diff --git a/Gvisual/src/gvisual/GraphMLExporter.java b/Gvisual/src/gvisual/GraphMLExporter.java index be986df..b54de46 100644 --- a/Gvisual/src/gvisual/GraphMLExporter.java +++ b/Gvisual/src/gvisual/GraphMLExporter.java @@ -32,8 +32,8 @@ */ public class GraphMLExporter { - private final Graph graph; - private final List allEdges; + private final Graph graph; + private final List allEdges; private String timestamp; private String description; @@ -43,12 +43,12 @@ public class GraphMLExporter { * @param graph the JUNG graph to export * @param allEdges all edges (including those not currently visible in graph) */ - public GraphMLExporter(Graph graph, List allEdges) { + public GraphMLExporter(Graph graph, List allEdges) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } this.graph = graph; - this.allEdges = (allEdges != null) ? allEdges : new ArrayList(); + this.allEdges = (allEdges != null) ? allEdges : new ArrayList(); this.timestamp = ""; this.description = ""; } @@ -109,9 +109,9 @@ public void export(File file) throws IOException { * @return the complete GraphML XML as a string */ public String exportToString() { - List edgesToExport = !allEdges.isEmpty() + List edgesToExport = !allEdges.isEmpty() ? allEdges - : new ArrayList(graph.getEdges()); + : new ArrayList(graph.getEdges()); return exportToString(edgesToExport); } @@ -121,7 +121,7 @@ public String exportToString() { * @return GraphML XML string with only visible edges */ public String exportVisibleToString() { - return exportToString(new ArrayList(graph.getEdges())); + return exportToString(new ArrayList(graph.getEdges())); } /** @@ -130,7 +130,7 @@ public String exportVisibleToString() { * @param edgesToExport the edges to include in the export * @return the complete GraphML XML as a string */ - private String exportToString(List edgesToExport) { + private String exportToString(List edgesToExport) { StringBuilder sb = new StringBuilder(); // XML header @@ -179,7 +179,7 @@ private String exportToString(List edgesToExport) { // Edges — use the provided edgesToExport list int edgeIndex = 0; - for (edge e : edgesToExport) { + for (Edge e : edgesToExport) { String edgeId = "e" + edgeIndex++; sb.append(" mergedGraph; + private final Graph mergedGraph; private final Strategy strategy; private final EdgeConflict edgeConflict; private final int vertexCountA; @@ -90,7 +90,7 @@ public static final class MergeResult { private final Set onlyInA; private final Set onlyInB; - MergeResult(Graph mergedGraph, Strategy strategy, + MergeResult(Graph mergedGraph, Strategy strategy, EdgeConflict edgeConflict, int vertexCountA, int vertexCountB, int edgeCountA, int edgeCountB, @@ -112,7 +112,7 @@ public static final class MergeResult { this.onlyInB = Collections.unmodifiableSet(onlyInB); } - public Graph getMergedGraph() { return mergedGraph; } + public Graph getMergedGraph() { return mergedGraph; } public Strategy getStrategy() { return strategy; } public EdgeConflict getEdgeConflict() { return edgeConflict; } public int getVertexCountA() { return vertexCountA; } @@ -155,7 +155,7 @@ public String getSummary() { /** * Merge two graphs with default settings (UNION + KEEP_LEFT). */ - public static MergeResult merge(Graph a, Graph b) { + public static MergeResult merge(Graph a, Graph b) { return merge(a, b, Strategy.UNION, EdgeConflict.KEEP_LEFT); } @@ -169,7 +169,7 @@ public static MergeResult merge(Graph a, Graph b) { * @return merge result with the combined graph and statistics * @throws IllegalArgumentException if any argument is null */ - public static MergeResult merge(Graph a, Graph b, + public static MergeResult merge(Graph a, Graph b, Strategy strategy, EdgeConflict edgeConflict) { if (a == null || b == null) throw new IllegalArgumentException("Graphs must not be null"); if (strategy == null) throw new IllegalArgumentException("Strategy must not be null"); @@ -187,7 +187,7 @@ public static MergeResult merge(Graph a, Graph b, Set onlyB = new HashSet<>(vertsB); onlyB.removeAll(vertsA); - Graph merged = new UndirectedSparseGraph<>(); + Graph merged = new UndirectedSparseGraph<>(); int[] conflicts = {0}; switch (strategy) { @@ -216,14 +216,14 @@ public static MergeResult merge(Graph a, Graph b, // ── Strategy Implementations ─────────────────────────────────── - private static void mergeUnion(Graph a, Graph b, - Graph result, + private static void mergeUnion(Graph a, Graph b, + Graph result, EdgeConflict conflict, int[] conflicts) { - Map edgeIndex = new HashMap<>(); + Map edgeIndex = new HashMap<>(); // Add all from A for (String v : a.getVertices()) result.addVertex(v); - for (edge e : a.getEdges()) { + for (Edge e : a.getEdges()) { String key = edgeKey(e); result.addEdge(cloneEdge(e), e.getVertex1(), e.getVertex2()); edgeIndex.put(key, findEdge(result, e.getVertex1(), e.getVertex2())); @@ -235,7 +235,7 @@ private static void mergeUnion(Graph a, Graph b, } // Add/merge edges from B - for (edge e : b.getEdges()) { + for (Edge e : b.getEdges()) { String key = edgeKey(e); if (edgeIndex.containsKey(key)) { // Conflict — resolve weight @@ -248,21 +248,21 @@ private static void mergeUnion(Graph a, Graph b, } } - private static void mergeIntersection(Graph a, Graph b, - Graph result, + private static void mergeIntersection(Graph a, Graph b, + Graph result, Set shared, EdgeConflict conflict, int[] conflicts) { // Add only shared vertices for (String v : shared) result.addVertex(v); // Build edge index for B - Map bEdges = new HashMap<>(); - for (edge e : b.getEdges()) { + Map bEdges = new HashMap<>(); + for (Edge e : b.getEdges()) { bEdges.put(edgeKey(e), e); } // Add edges present in both graphs (between shared vertices) - for (edge e : a.getEdges()) { + for (Edge e : a.getEdges()) { if (!shared.contains(e.getVertex1()) || !shared.contains(e.getVertex2())) continue; String key = edgeKey(e); @@ -276,21 +276,21 @@ private static void mergeIntersection(Graph a, Graph } } - private static void mergeSymmetricDifference(Graph a, Graph b, - Graph result, + private static void mergeSymmetricDifference(Graph a, Graph b, + Graph result, Set shared) { // Build edge sets Set aEdgeKeys = new HashSet<>(); - for (edge e : a.getEdges()) aEdgeKeys.add(edgeKey(e)); + for (Edge e : a.getEdges()) aEdgeKeys.add(edgeKey(e)); Set bEdgeKeys = new HashSet<>(); - for (edge e : b.getEdges()) bEdgeKeys.add(edgeKey(e)); + for (Edge e : b.getEdges()) bEdgeKeys.add(edgeKey(e)); // Add vertices that appear in edges unique to one graph Set addedVerts = new HashSet<>(); // Edges only in A - for (edge e : a.getEdges()) { + for (Edge e : a.getEdges()) { if (!bEdgeKeys.contains(edgeKey(e))) { ensureVertex(result, e.getVertex1(), addedVerts); ensureVertex(result, e.getVertex2(), addedVerts); @@ -299,7 +299,7 @@ private static void mergeSymmetricDifference(Graph a, Graph a, Graph primary, Graph secondary, - Graph result, + private static void mergeLeftJoin(Graph primary, Graph secondary, + Graph result, EdgeConflict conflict, int[] conflicts) { // Add all vertices and edges from primary for (String v : primary.getVertices()) result.addVertex(v); - Map edgeIndex = new HashMap<>(); - for (edge e : primary.getEdges()) { + Map edgeIndex = new HashMap<>(); + for (Edge e : primary.getEdges()) { result.addEdge(cloneEdge(e), e.getVertex1(), e.getVertex2()); edgeIndex.put(edgeKey(e), findEdge(result, e.getVertex1(), e.getVertex2())); } // Add edges from secondary that connect primary's vertices Set primaryVerts = new HashSet<>(primary.getVertices()); - for (edge e : secondary.getEdges()) { + for (Edge e : secondary.getEdges()) { if (!primaryVerts.contains(e.getVertex1()) || !primaryVerts.contains(e.getVertex2())) { continue; } @@ -348,21 +348,21 @@ private static void mergeLeftJoin(Graph primary, Graph g, String v1, String v2) { + private static edge findEdge(Graph g, String v1, String v2) { edge e = g.findEdge(v1, v2); return e != null ? e : g.findEdge(v2, v1); } /** Clone an edge (deep copy). */ - private static edge cloneEdge(edge e) { - edge clone = new edge(e.getType(), e.getVertex1(), e.getVertex2()); + private static edge cloneEdge(Edge e) { + edge clone = new Edge(e.getType(), e.getVertex1(), e.getVertex2()); clone.setWeight(e.getWeight()); clone.setLabel(e.getLabel()); clone.setTimestamp(e.getTimestamp()); @@ -371,7 +371,7 @@ private static edge cloneEdge(edge e) { } /** Add vertex to graph if not already present. */ - private static void ensureVertex(Graph g, String v, Set tracker) { + private static void ensureVertex(Graph g, String v, Set tracker) { if (!tracker.contains(v)) { if (!g.containsVertex(v)) g.addVertex(v); tracker.add(v); diff --git a/Gvisual/src/gvisual/GraphMinorAnalyzer.java b/Gvisual/src/gvisual/GraphMinorAnalyzer.java index e1ffccc..6e8c804 100644 --- a/Gvisual/src/gvisual/GraphMinorAnalyzer.java +++ b/Gvisual/src/gvisual/GraphMinorAnalyzer.java @@ -29,9 +29,9 @@ */ public class GraphMinorAnalyzer { - private final Graph graph; + private final Graph graph; - public GraphMinorAnalyzer(Graph graph) { + public GraphMinorAnalyzer(Graph graph) { if (graph == null) throw new IllegalArgumentException("Graph must not be null"); this.graph = graph; } @@ -41,14 +41,14 @@ public GraphMinorAnalyzer(Graph graph) { /** * Creates a deep copy of a graph. */ - public static Graph copyGraph(Graph g) { - Graph copy = new UndirectedSparseGraph<>(); + public static Graph copyGraph(Graph g) { + Graph copy = new UndirectedSparseGraph<>(); for (String v : g.getVertices()) copy.addVertex(v); - for (edge e : g.getEdges()) { + for (Edge e : g.getEdges()) { Collection endpoints = g.getEndpoints(e); Iterator it = endpoints.iterator(); String v1 = it.next(), v2 = it.next(); - copy.addEdge(new edge(e.getType(), v1, v2), v1, v2); + copy.addEdge(new Edge(e.getType(), v1, v2), v1, v2); } return copy; } @@ -58,10 +58,10 @@ public static Graph copyGraph(Graph g) { /** * Returns a new graph with the given vertex removed. */ - public Graph deleteVertex(String vertex) { + public Graph deleteVertex(String vertex) { if (!graph.containsVertex(vertex)) throw new IllegalArgumentException("Vertex not found: " + vertex); - Graph result = copyGraph(graph); + Graph result = copyGraph(graph); result.removeVertex(vertex); return result; } @@ -69,8 +69,8 @@ public Graph deleteVertex(String vertex) { /** * Returns a new graph with the given vertices removed. */ - public Graph deleteVertices(Collection vertices) { - Graph result = copyGraph(graph); + public Graph deleteVertices(Collection vertices) { + Graph result = copyGraph(graph); for (String v : vertices) result.removeVertex(v); return result; } @@ -80,8 +80,8 @@ public Graph deleteVertices(Collection vertices) { /** * Returns a new graph with the edge between v1 and v2 removed. */ - public Graph deleteEdge(String v1, String v2) { - Graph result = copyGraph(graph); + public Graph deleteEdge(String v1, String v2) { + Graph result = copyGraph(graph); edge e = result.findEdge(v1, v2); if (e == null) throw new IllegalArgumentException("No edge between " + v1 + " and " + v2); result.removeEdge(e); @@ -94,10 +94,10 @@ public Graph deleteEdge(String v1, String v2) { * Contracts the edge between v1 and v2, merging v2 into v1. * Returns a new graph. The merged vertex keeps v1's name. */ - public static Graph contractEdge(Graph g, String v1, String v2) { + public static Graph contractEdge(Graph g, String v1, String v2) { if (g.findEdge(v1, v2) == null) throw new IllegalArgumentException("No edge between " + v1 + " and " + v2); - Graph result = copyGraph(g); + Graph result = copyGraph(g); // Get v2's neighbors (excluding v1) Collection v2Neighbors = new ArrayList<>(result.getNeighbors(v2)); v2Neighbors.remove(v1); @@ -105,7 +105,7 @@ public static Graph contractEdge(Graph g, String v1, int eid = result.getEdgeCount(); for (String n : v2Neighbors) { if (result.findEdge(v1, n) == null) { - result.addEdge(new edge("contracted_" + eid++, v1, n), v1, n); + result.addEdge(new Edge("contracted_" + eid++, v1, n), v1, n); } } result.removeVertex(v2); @@ -115,7 +115,7 @@ public static Graph contractEdge(Graph g, String v1, /** * Contracts the edge between v1 and v2 on the instance graph. */ - public Graph contractEdge(String v1, String v2) { + public Graph contractEdge(String v1, String v2) { return contractEdge(graph, v1, v2); } @@ -152,8 +152,8 @@ public String toString() { /** * Applies a sequence of minor operations starting from the instance graph. */ - public Graph applySequence(List ops) { - Graph g = copyGraph(graph); + public Graph applySequence(List ops) { + Graph g = copyGraph(graph); for (MinorOp op : ops) { switch (op.type) { case DELETE_VERTEX: @@ -185,7 +185,7 @@ public int hadwigerNumber() { if (graph.getEdgeCount() == 0) return 1; // Build adjacency - Graph g = copyGraph(graph); + Graph g = copyGraph(graph); int best = 1; // Greedy: find largest complete minor by contracting edges @@ -203,7 +203,7 @@ public int hadwigerNumber() { // Find best edge to contract: endpoints sharing most neighbors String bestV1 = null, bestV2 = null; int bestScore = -1; - for (edge e : g.getEdges()) { + for (Edge e : g.getEdges()) { Collection ep = g.getEndpoints(e); Iterator it = ep.iterator(); String a = it.next(), b = it.next(); @@ -224,7 +224,7 @@ public int hadwigerNumber() { return best; } - private int findLargestClique(Graph g) { + private int findLargestClique(Graph g) { // Simple greedy clique finder List vertices = new ArrayList<>(g.getVertices()); vertices.sort((a, b) -> Integer.compare(g.degree(b), g.degree(a))); @@ -270,7 +270,7 @@ public boolean hasK33Minor() { if (graph.getEdgeCount() < 9) return false; // Try contracting graph down and checking for K33 - Graph g = copyGraph(graph); + Graph g = copyGraph(graph); // Remove degree-1 vertices iteratively (they can't help with K33) boolean changed = true; @@ -296,7 +296,7 @@ public boolean hasK33Minor() { return findK33Contraction(g); } - private boolean findK33Brute(Graph g, List verts) { + private boolean findK33Brute(Graph g, List verts) { int n = verts.size(); // Try all combinations of 3+3 for (int i = 0; i < n - 5; i++) @@ -312,19 +312,19 @@ private boolean findK33Brute(Graph g, List verts) { return false; } - private boolean isCompleteBipartite(Graph g, String[] left, String[] right) { + private boolean isCompleteBipartite(Graph g, String[] left, String[] right) { for (String l : left) for (String r : right) if (g.findEdge(l, r) == null) return false; return true; } - private boolean findK33Contraction(Graph g) { + private boolean findK33Contraction(Graph g) { // Contract high-degree edges and check smaller graph while (g.getVertexCount() > 15 && g.getEdgeCount() > 0) { edge e = null; int bestDeg = -1; - for (edge candidate : g.getEdges()) { + for (Edge candidate : g.getEdges()) { Collection ep = g.getEndpoints(candidate); Iterator it = ep.iterator(); String a = it.next(), b = it.next(); @@ -412,14 +412,14 @@ public int contractionDegeneracy() { * Subdivides an edge: replaces edge (v1,v2) with v1-new-v2. * Returns a new graph with the subdivision vertex added. */ - public Graph subdivideEdge(String v1, String v2, String newVertex) { - Graph result = copyGraph(graph); + public Graph subdivideEdge(String v1, String v2, String newVertex) { + Graph result = copyGraph(graph); edge e = result.findEdge(v1, v2); if (e == null) throw new IllegalArgumentException("No edge between " + v1 + " and " + v2); result.removeEdge(e); result.addVertex(newVertex); - result.addEdge(new edge("sub_a", v1, newVertex), v1, newVertex); - result.addEdge(new edge("sub_b", newVertex, v2), newVertex, v2); + result.addEdge(new Edge("sub_a", v1, newVertex), v1, newVertex); + result.addEdge(new Edge("sub_b", newVertex, v2), newVertex, v2); return result; } diff --git a/Gvisual/src/gvisual/GraphNeighborhoodAnalyzer.java b/Gvisual/src/gvisual/GraphNeighborhoodAnalyzer.java index ed5dfb1..6328fbd 100644 --- a/Gvisual/src/gvisual/GraphNeighborhoodAnalyzer.java +++ b/Gvisual/src/gvisual/GraphNeighborhoodAnalyzer.java @@ -35,7 +35,7 @@ */ public class GraphNeighborhoodAnalyzer { - private final Graph graph; + private final Graph graph; /** * Constructs an analyser for the given graph. @@ -43,7 +43,7 @@ public class GraphNeighborhoodAnalyzer { * @param graph the graph to analyse (must not be null) * @throws IllegalArgumentException if graph is null */ - public GraphNeighborhoodAnalyzer(Graph graph) { + public GraphNeighborhoodAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -204,7 +204,7 @@ public double getLocalDensity(String source, int k) { } int edgeCount = 0; - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String src = graph.getEndpoints(e).getFirst(); String dst = graph.getEndpoints(e).getSecond(); if (neighborhood.contains(src) && neighborhood.contains(dst)) { diff --git a/Gvisual/src/gvisual/GraphNetworkProfiler.java b/Gvisual/src/gvisual/GraphNetworkProfiler.java index 6d71a91..4a55c3c 100644 --- a/Gvisual/src/gvisual/GraphNetworkProfiler.java +++ b/Gvisual/src/gvisual/GraphNetworkProfiler.java @@ -130,7 +130,7 @@ public MetricResult(String name, String category, double value, public String getInterpretation() { return interpretation; } } - private final Graph graph; + private final Graph graph; private final Random random; private boolean analyzed; @@ -155,11 +155,11 @@ public MetricResult(String name, String category, double value, private static final int SAMPLE_SIZE = 50; - public GraphNetworkProfiler(Graph graph) { + public GraphNetworkProfiler(Graph graph) { this(graph, new Random(42)); } - public GraphNetworkProfiler(Graph graph, Random random) { + public GraphNetworkProfiler(Graph graph, Random random) { this.graph = Objects.requireNonNull(graph, "graph must not be null"); this.random = random; this.analyzed = false; @@ -253,7 +253,7 @@ private void computeAssortativity() { if (graph.getEdgeCount() == 0) { assortativity = 0; return; } double sumProd = 0, sumI = 0, sumJ = 0, sumISq = 0, sumJSq = 0; int m = graph.getEdgeCount(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); int di = graph.degree(v1); diff --git a/Gvisual/src/gvisual/GraphPartitioner.java b/Gvisual/src/gvisual/GraphPartitioner.java index b3753bb..a555d49 100644 --- a/Gvisual/src/gvisual/GraphPartitioner.java +++ b/Gvisual/src/gvisual/GraphPartitioner.java @@ -42,7 +42,7 @@ public enum Strategy { SPECTRAL } - private final Graph graph; + private final Graph graph; /** * Creates a new GraphPartitioner for the given graph. @@ -50,7 +50,7 @@ public enum Strategy { * @param graph the JUNG graph to partition * @throws IllegalArgumentException if graph is null */ - public GraphPartitioner(Graph graph) { + public GraphPartitioner(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -606,7 +606,7 @@ public static class PartitionResult { private final double cutRatio; private final List partitions; - PartitionResult(Map assignment, int k, Graph graph) { + PartitionResult(Map assignment, int k, Graph graph) { this.assignment = Collections.unmodifiableMap(new HashMap<>(assignment)); this.k = k; @@ -624,7 +624,7 @@ public static class PartitionResult { Map internalEdges = new HashMap<>(); Map externalEdges = new HashMap<>(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { Collection endpoints = graph.getEndpoints(e); if (endpoints.size() < 2) continue; Iterator it = endpoints.iterator(); diff --git a/Gvisual/src/gvisual/GraphPathExplorer.java b/Gvisual/src/gvisual/GraphPathExplorer.java index ced2b6a..e3cf49c 100644 --- a/Gvisual/src/gvisual/GraphPathExplorer.java +++ b/Gvisual/src/gvisual/GraphPathExplorer.java @@ -39,7 +39,7 @@ public class GraphPathExplorer { /** Default maximum number of paths to return. */ private static final int DEFAULT_MAX_PATHS = 1000; - private final Graph graph; + private final Graph graph; private final Map> adjacency; private final Map> weightMap; @@ -51,7 +51,7 @@ public class GraphPathExplorer { * @param graph the JUNG graph to explore * @throws IllegalArgumentException if graph is null or empty */ - public GraphPathExplorer(Graph graph) { + public GraphPathExplorer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -65,7 +65,7 @@ public GraphPathExplorer(Graph graph) { private Map> buildWeightMap() { Map> wm = new HashMap<>(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); float w = e.getWeight() > 0 ? e.getWeight() : 1.0f; diff --git a/Gvisual/src/gvisual/GraphPathExplorerTest.java b/Gvisual/src/gvisual/GraphPathExplorerTest.java index bbdbbd4..f935383 100644 --- a/Gvisual/src/gvisual/GraphPathExplorerTest.java +++ b/Gvisual/src/gvisual/GraphPathExplorerTest.java @@ -21,8 +21,8 @@ public class GraphPathExplorerTest { /** * Linear: A - B - C - D - E */ - private static Graph linearGraph() { - Graph g = new UndirectedSparseGraph<>(); + private static Graph linearGraph() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addVertex("E"); addEdge(g, "A", "B", 1); addEdge(g, "B", "C", 1); @@ -37,8 +37,8 @@ private static Graph linearGraph() { * \ / * D */ - private static Graph diamondGraph() { - Graph g = new UndirectedSparseGraph<>(); + private static Graph diamondGraph() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); addEdge(g, "A", "B", 1); addEdge(g, "A", "C", 1); @@ -54,8 +54,8 @@ private static Graph diamondGraph() { * | | | * G - H - I */ - private static Graph gridGraph() { - Graph g = new UndirectedSparseGraph<>(); + private static Graph gridGraph() { + Graph g = new UndirectedSparseGraph<>(); String[] nodes = {"A","B","C","D","E","F","G","H","I"}; for (String n : nodes) g.addVertex(n); // Horizontal @@ -76,8 +76,8 @@ private static Graph gridGraph() { * | | * D -1- E */ - private static Graph weightedGraph() { - Graph g = new UndirectedSparseGraph<>(); + private static Graph weightedGraph() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addVertex("E"); addEdge(g, "A", "B", 1); addEdge(g, "B", "C", 2); @@ -89,8 +89,8 @@ private static Graph weightedGraph() { /** * Disconnected: A - B - C D - E */ - private static Graph disconnectedGraph() { - Graph g = new UndirectedSparseGraph<>(); + private static Graph disconnectedGraph() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addVertex("E"); addEdge(g, "A", "B", 1); addEdge(g, "B", "C", 1); @@ -101,8 +101,8 @@ private static Graph disconnectedGraph() { /** * Complete K4: A, B, C, D — all connected */ - private static Graph completeK4() { - Graph g = new UndirectedSparseGraph<>(); + private static Graph completeK4() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); addEdge(g, "A", "B", 1); addEdge(g, "A", "C", 1); @@ -117,8 +117,8 @@ private static Graph completeK4() { * E - F - X (same X) * X is the only path between {A,B} and {C,D,E,F} */ - private static Graph bottleneckGraph() { - Graph g = new UndirectedSparseGraph<>(); + private static Graph bottleneckGraph() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("X"); g.addVertex("C"); g.addVertex("D"); addEdge(g, "A", "B", 1); addEdge(g, "B", "X", 1); @@ -127,8 +127,8 @@ private static Graph bottleneckGraph() { } private static int edgeCounter = 0; - private static void addEdge(Graph g, String v1, String v2, float w) { - edge e = new edge("e", v1, v2); + private static void addEdge(Graph g, String v1, String v2, float w) { + edge e = new Edge("e", v1, v2); e.setWeight(w); e.setLabel("e" + (edgeCounter++)); g.addEdge(e, v1, v2); @@ -192,7 +192,7 @@ private static void testConstructor() { checkThrows("empty graph", () -> new GraphPathExplorer(new UndirectedSparseGraph<>()), IllegalArgumentException.class); - Graph g = linearGraph(); + Graph g = linearGraph(); GraphPathExplorer ex = new GraphPathExplorer(g); check("valid construction", ex != null); } @@ -345,7 +345,7 @@ private static void testAvoidanceRouting() { avoidEdges.add(GraphPathExplorer.edgeKey("A", "B")); p = dia.findPathAvoiding("A", "D", null, avoidEdges); check("diamond: avoid A-B edge exists", p != null); - check("diamond: goes through C (edge avoided)", + check("diamond: goes through C (Edge avoided)", p.getVertices().contains("C")); // Avoid source returns null diff --git a/Gvisual/src/gvisual/GraphProductCalculator.java b/Gvisual/src/gvisual/GraphProductCalculator.java index 8c0c6f9..fadec85 100644 --- a/Gvisual/src/gvisual/GraphProductCalculator.java +++ b/Gvisual/src/gvisual/GraphProductCalculator.java @@ -25,10 +25,10 @@ *

    Usage:

    *
    {@code
      * GraphProductCalculator calc = new GraphProductCalculator(graphG, graphH);
    - * Graph cartesian = calc.cartesianProduct();
    - * Graph tensor = calc.tensorProduct();
    - * Graph strong = calc.strongProduct();
    - * Graph lex = calc.lexicographicProduct();
    + * Graph cartesian = calc.cartesianProduct();
    + * Graph tensor = calc.tensorProduct();
    + * Graph strong = calc.strongProduct();
    + * Graph lex = calc.lexicographicProduct();
      *
      * // Product metadata
      * ProductInfo info = calc.getProductInfo(ProductType.CARTESIAN);
    @@ -95,11 +95,11 @@ public String toString() {
             }
         }
     
    -    private final Graph graphG;
    -    private final Graph graphH;
    +    private final Graph graphG;
    +    private final Graph graphH;
         private final List verticesG;
         private final List verticesH;
    -    private final Map> cache;
    +    private final Map> cache;
         private final Map infoCache;
     
         /**
    @@ -109,7 +109,7 @@ public String toString() {
          * @param graphH the second graph (H)
          * @throws IllegalArgumentException if either graph is null
          */
    -    public GraphProductCalculator(Graph graphG, Graph graphH) {
    +    public GraphProductCalculator(Graph graphG, Graph graphH) {
             if (graphG == null || graphH == null) {
                 throw new IllegalArgumentException("Both graphs must be non-null");
             }
    @@ -117,7 +117,7 @@ public GraphProductCalculator(Graph graphG, Graph gr
             this.graphH = graphH;
             this.verticesG = new ArrayList(graphG.getVertices());
             this.verticesH = new ArrayList(graphH.getVertices());
    -        this.cache = new EnumMap>(ProductType.class);
    +        this.cache = new EnumMap>(ProductType.class);
             this.infoCache = new EnumMap(ProductType.class);
         }
     
    @@ -131,7 +131,7 @@ private String productVertex(String u, String v) {
         /**
          * Checks if two vertices are adjacent in the given graph.
          */
    -    private boolean areAdjacent(Graph g, String v1, String v2) {
    +    private boolean areAdjacent(Graph g, String v1, String v2) {
             return g.findEdge(v1, v2) != null;
         }
     
    @@ -141,7 +141,7 @@ private boolean areAdjacent(Graph g, String v1, String v2) {
          * Creates a fresh product edge.
          */
         private edge newProductEdge(String u1, String v1, String u2, String v2) {
    -        edge e = new edge("product",
    +        edge e = new Edge("product",
                     productVertex(u1, v1),
                     productVertex(u2, v2));
             e.setLabel("e" + (edgeCounter++));
    @@ -155,12 +155,12 @@ private edge newProductEdge(String u1, String v1, String u2, String v2) {
          *
          * @return the Cartesian product graph
          */
    -    public Graph cartesianProduct() {
    +    public Graph cartesianProduct() {
             if (cache.containsKey(ProductType.CARTESIAN)) {
                 return cache.get(ProductType.CARTESIAN);
             }
             long start = System.currentTimeMillis();
    -        Graph product = new UndirectedSparseGraph();
    +        Graph product = new UndirectedSparseGraph();
     
             // Add all product vertices
             for (String u : verticesG) {
    @@ -213,12 +213,12 @@ public Graph cartesianProduct() {
          *
          * @return the tensor product graph
          */
    -    public Graph tensorProduct() {
    +    public Graph tensorProduct() {
             if (cache.containsKey(ProductType.TENSOR)) {
                 return cache.get(ProductType.TENSOR);
             }
             long start = System.currentTimeMillis();
    -        Graph product = new UndirectedSparseGraph();
    +        Graph product = new UndirectedSparseGraph();
     
             for (String u : verticesG) {
                 for (String v : verticesH) {
    @@ -263,12 +263,12 @@ public Graph tensorProduct() {
          *
          * @return the strong product graph
          */
    -    public Graph strongProduct() {
    +    public Graph strongProduct() {
             if (cache.containsKey(ProductType.STRONG)) {
                 return cache.get(ProductType.STRONG);
             }
             long start = System.currentTimeMillis();
    -        Graph product = new UndirectedSparseGraph();
    +        Graph product = new UndirectedSparseGraph();
     
             for (String u : verticesG) {
                 for (String v : verticesH) {
    @@ -318,7 +318,7 @@ public Graph strongProduct() {
                     else if (uAdj && vAdj) connected = true;    // Tensor
     
                     if (connected) {
    -                    edge e = new edge("product", pv1, pv2);
    +                    edge e = new Edge("product", pv1, pv2);
                         e.setLabel("e" + (edgeCounter++));
                         product.addEdge(e, pv1, pv2);
                     }
    @@ -341,12 +341,12 @@ public Graph strongProduct() {
          *
          * @return the lexicographic product graph
          */
    -    public Graph lexicographicProduct() {
    +    public Graph lexicographicProduct() {
             if (cache.containsKey(ProductType.LEXICOGRAPHIC)) {
                 return cache.get(ProductType.LEXICOGRAPHIC);
             }
             long start = System.currentTimeMillis();
    -        Graph product = new UndirectedSparseGraph();
    +        Graph product = new UndirectedSparseGraph();
     
             for (String u : verticesG) {
                 for (String v : verticesH) {
    @@ -462,7 +462,7 @@ public String getReport() {
          * @return sorted degree sequence (descending)
          */
         public List getDegreeSequence(ProductType type) {
    -        Graph product;
    +        Graph product;
             switch (type) {
                 case CARTESIAN: product = cartesianProduct(); break;
                 case TENSOR: product = tensorProduct(); break;
    diff --git a/Gvisual/src/gvisual/GraphQueryEngine.java b/Gvisual/src/gvisual/GraphQueryEngine.java
    index b95c602..3873b00 100644
    --- a/Gvisual/src/gvisual/GraphQueryEngine.java
    +++ b/Gvisual/src/gvisual/GraphQueryEngine.java
    @@ -42,9 +42,9 @@
      */
     public class GraphQueryEngine {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
    -    public GraphQueryEngine(Graph graph) {
    +    public GraphQueryEngine(Graph graph) {
             this.graph = Objects.requireNonNull(graph, "graph must not be null");
         }
     
    @@ -104,7 +104,7 @@ public QueryStats stats() {
             }
             if (nodeCount == 0) minDeg = 0;
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String t = e.getType() != null ? e.getType() : "unknown";
                 typeCounts.merge(t, 1, Integer::sum);
             }
    @@ -119,10 +119,10 @@ public QueryStats stats() {
          * Chainable builder for filtering graph vertices.
          */
         public static class NodeQuery {
    -        private final Graph graph;
    +        private final Graph graph;
             private final List> filters = new ArrayList<>();
     
    -        NodeQuery(Graph graph) {
    +        NodeQuery(Graph graph) {
                 this.graph = graph;
             }
     
    @@ -172,7 +172,7 @@ public NodeQuery inSet(Set allowed) {
             /** Keep only nodes that have at least one edge of the given type. */
             public NodeQuery connectedByType(String edgeType) {
                 filters.add(v -> {
    -                for (edge e : graph.getIncidentEdges(v)) {
    +                for (Edge e : graph.getIncidentEdges(v)) {
                         if (edgeType.equals(e.getType())) return true;
                     }
                     return false;
    @@ -247,10 +247,10 @@ public String summary() {
          * Chainable builder for filtering graph edges.
          */
         public static class EdgeQuery {
    -        private final Graph graph;
    +        private final Graph graph;
             private final List> filters = new ArrayList<>();
     
    -        EdgeQuery(Graph graph) {
    +        EdgeQuery(Graph graph) {
                 this.graph = graph;
             }
     
    @@ -321,7 +321,7 @@ public EdgeQuery where(Predicate predicate) {
             }
     
             /** Execute the query and return matching edges. */
    -        public Set results() {
    +        public Set results() {
                 return graph.getEdges().stream()
                         .filter(e -> filters.stream().allMatch(f -> f.test(e)))
                         .collect(Collectors.toCollection(LinkedHashSet::new));
    @@ -333,7 +333,7 @@ public int count() {
             }
     
             /** Execute and return results sorted by weight (descending). */
    -        public List sortedByWeight() {
    +        public List sortedByWeight() {
                 return results().stream()
                         .sorted(Comparator.comparing(edge::getWeight).reversed())
                         .collect(Collectors.toList());
    @@ -342,7 +342,7 @@ public List sortedByWeight() {
             /** Execute and return a type breakdown of matching edges. */
             public Map typeBreakdown() {
                 Map counts = new LinkedHashMap<>();
    -            for (edge e : results()) {
    +            for (Edge e : results()) {
                     String t = e.getType() != null ? e.getType() : "unknown";
                     counts.merge(t, 1, Integer::sum);
                 }
    @@ -351,12 +351,12 @@ public Map typeBreakdown() {
     
             /** Execute and return a summary string for display. */
             public String summary() {
    -            Set r = results();
    +            Set r = results();
                 if (r.isEmpty()) return "No matching edges.";
                 StringBuilder sb = new StringBuilder();
                 sb.append(String.format("Found %d edge(s):\n", r.size()));
                 int shown = 0;
    -            for (edge e : r) {
    +            for (Edge e : r) {
                     sb.append(String.format("  %s --%s--> %s  (w=%.2f)\n",
                             e.getVertex1(), e.getType(), e.getVertex2(), e.getWeight()));
                     if (++shown >= 50) {
    diff --git a/Gvisual/src/gvisual/GraphRenderers.java b/Gvisual/src/gvisual/GraphRenderers.java
    index 3434090..1543162 100644
    --- a/Gvisual/src/gvisual/GraphRenderers.java
    +++ b/Gvisual/src/gvisual/GraphRenderers.java
    @@ -25,30 +25,30 @@ public class GraphRenderers {
     
         // ── overlay state (set externally by Main) ──────────────────────────
     
    -    private Set pathEdges;
    +    private Set pathEdges;
         private Set pathVertices;
         private String pathSource;
         private String pathTarget;
     
         private boolean mstOverlayActive;
    -    private Set mstEdges;
    +    private Set mstEdges;
     
         private boolean communityOverlayActive;
         private Map nodeCommunityMap;
     
         private boolean articulationOverlayActive;
         private Set articulationPoints;
    -    private Set bridgeEdges;
    +    private Set bridgeEdges;
     
         private boolean egoOverlayActive;
         private String egoCenter;
         private Set egoNeighbors;
    -    private Set egoEdges;
    +    private Set egoEdges;
     
         private Collection oldVertices;
     
         /** Graph reference for vertex‐paint edge‐type lookup. */
    -    private Graph graph;
    +    private Graph graph;
     
         // ── constants (mirrored from Main) ──────────────────────────────────
     
    @@ -71,7 +71,7 @@ public class GraphRenderers {
     
         // ── setters ─────────────────────────────────────────────────────────
     
    -    public void setPathState(Set pathEdges, Set pathVertices,
    +    public void setPathState(Set pathEdges, Set pathVertices,
                                  String pathSource, String pathTarget) {
             this.pathEdges = pathEdges;
             this.pathVertices = pathVertices;
    @@ -79,7 +79,7 @@ public void setPathState(Set pathEdges, Set pathVertices,
             this.pathTarget = pathTarget;
         }
     
    -    public void setMstState(boolean active, Set mstEdges) {
    +    public void setMstState(boolean active, Set mstEdges) {
             this.mstOverlayActive = active;
             this.mstEdges = mstEdges;
         }
    @@ -90,13 +90,13 @@ public void setCommunityState(boolean active, Map nodeCommunity
         }
     
         public void setArticulationState(boolean active, Set articulationPoints,
    -                                     Set bridgeEdges) {
    +                                     Set bridgeEdges) {
             this.articulationOverlayActive = active;
             this.articulationPoints = articulationPoints;
             this.bridgeEdges = bridgeEdges;
         }
     
    -    public void setEgoState(boolean active, String center, Set neighbors, Set edges) {
    +    public void setEgoState(boolean active, String center, Set neighbors, Set edges) {
             this.egoOverlayActive = active;
             this.egoCenter = center;
             this.egoNeighbors = neighbors;
    @@ -107,14 +107,14 @@ public void setOldVertices(Collection oldVertices) {
             this.oldVertices = oldVertices;
         }
     
    -    public void setGraph(Graph graph) {
    +    public void setGraph(Graph graph) {
             this.graph = graph;
         }
     
         // ── transformers ────────────────────────────────────────────────────
     
         public Transformer edgePaintTransformer() {
    -        return (edge e) -> {
    +        return (Edge e) -> {
                     if (pathEdges != null && pathEdges.contains(e)) {
                         return Color.YELLOW;
                     }
    @@ -179,7 +179,7 @@ public Transformer vertexPaintTransformer() {
                     // Determine vertex colour based on connected edge types
                     if (graph != null) {
                         Set connectedTypes = new HashSet<>();
    -                    for (edge x : graph.getOutEdges(vertex)) {
    +                    for (Edge x : graph.getOutEdges(vertex)) {
                             EdgeType et = EdgeType.fromCode(x.getType());
                             if (et != null) {
                                 connectedTypes.add(et);
    @@ -230,7 +230,7 @@ public Transformer vertexShapeTransformer() {
         }
     
         public Transformer edgeStrokeTransformer() {
    -        return (edge i) -> {
    +        return (Edge i) -> {
                     if (pathEdges != null && pathEdges.contains(i)) {
                         return new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
                     }
    diff --git a/Gvisual/src/gvisual/GraphResilienceAnalyzer.java b/Gvisual/src/gvisual/GraphResilienceAnalyzer.java
    index fc5f8ad..e636b55 100644
    --- a/Gvisual/src/gvisual/GraphResilienceAnalyzer.java
    +++ b/Gvisual/src/gvisual/GraphResilienceAnalyzer.java
    @@ -22,7 +22,7 @@
      */
     public class GraphResilienceAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private List degreeAttackCurve;
         private List betweennessAttackCurve;
         private List randomAttackCurve;
    @@ -34,7 +34,7 @@ public class GraphResilienceAnalyzer {
          *
          * @param graph the JUNG graph to analyze
          */
    -    public GraphResilienceAnalyzer(Graph graph) {
    +    public GraphResilienceAnalyzer(Graph graph) {
             this.graph = graph;
             this.randomTrials = 10;
             this.computed = false;
    @@ -174,7 +174,7 @@ public String exportCSV() {
         // --- Private simulation methods ---
     
         private List simulateDegreeAttack() {
    -        Graph copy = copyGraph();
    +        Graph copy = copyGraph();
             List curve = new ArrayList<>();
             int originalSize = copy.getVertexCount();
     
    @@ -199,7 +199,7 @@ private List simulateDegreeAttack() {
         }
     
         private List simulateBetweennessAttack() {
    -        Graph copy = copyGraph();
    +        Graph copy = copyGraph();
             List curve = new ArrayList<>();
             int originalSize = copy.getVertexCount();
     
    @@ -231,7 +231,7 @@ private List simulateRandomAttack(int trials) {
     
             Random rng = new Random(42);
             for (int t = 0; t < trials; t++) {
    -            Graph copy = copyGraph();
    +            Graph copy = copyGraph();
                 List vertices = new ArrayList<>(copy.getVertices());
                 Collections.shuffle(vertices, rng);
     
    @@ -259,11 +259,11 @@ private List simulateRandomAttack(int trials) {
             return curve;
         }
     
    -    private Graph copyGraph() {
    +    private Graph copyGraph() {
             return GraphUtils.copyGraph(graph);
         }
     
    -    private ResilienceStep captureStep(Graph g, int originalSize,
    +    private ResilienceStep captureStep(Graph g, int originalSize,
                                             int step, String removedNode) {
             return new ResilienceStep(
                     step,
    @@ -274,21 +274,21 @@ private ResilienceStep captureStep(Graph g, int originalSize,
                     removedNode);
         }
     
    -    private int largestComponentSize(Graph g) {
    +    private int largestComponentSize(Graph g) {
             if (g.getVertexCount() == 0) return 0;
             return GraphUtils.findLargestComponent(g).size();
         }
     
    -    private int countComponents(Graph g) {
    +    private int countComponents(Graph g) {
             if (g.getVertexCount() == 0) return 0;
             return GraphUtils.findComponents(g).size();
         }
     
    -    private double globalEfficiency(Graph g) {
    +    private double globalEfficiency(Graph g) {
             return GraphUtils.globalEfficiency(g);
         }
     
    -    private Map computeBetweenness(Graph g) {
    +    private Map computeBetweenness(Graph g) {
             return GraphUtils.computeBetweenness(g);
         }
     
    diff --git a/Gvisual/src/gvisual/GraphSampler.java b/Gvisual/src/gvisual/GraphSampler.java
    index 8a256c4..c932336 100644
    --- a/Gvisual/src/gvisual/GraphSampler.java
    +++ b/Gvisual/src/gvisual/GraphSampler.java
    @@ -43,7 +43,7 @@
      */
     public class GraphSampler {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private final Random rng;
     
         /**
    @@ -52,7 +52,7 @@ public class GraphSampler {
          * @param graph the source graph
          * @throws IllegalArgumentException if graph is null
          */
    -    public GraphSampler(Graph graph) {
    +    public GraphSampler(Graph graph) {
             this(graph, new Random());
         }
     
    @@ -62,7 +62,7 @@ public GraphSampler(Graph graph) {
          * @param graph the source graph
          * @param rng   random number generator
          */
    -    public GraphSampler(Graph graph, Random rng) {
    +    public GraphSampler(Graph graph, Random rng) {
             if (graph == null) throw new IllegalArgumentException("Graph must not be null");
             if (rng == null) throw new IllegalArgumentException("RNG must not be null");
             this.graph = graph;
    @@ -107,11 +107,11 @@ public SampleResult randomEdge(double fraction) {
             int m = graph.getEdgeCount();
             int target = Math.max(1, (int) Math.ceil(m * fraction));
     
    -        List edges = new ArrayList(graph.getEdges());
    +        List edges = new ArrayList(graph.getEdges());
             Collections.shuffle(edges, rng);
     
             Set sampled = new LinkedHashSet();
    -        Set sampledEdges = new LinkedHashSet();
    +        Set sampledEdges = new LinkedHashSet();
             for (int i = 0; i < Math.min(target, edges.size()); i++) {
                 edge e = edges.get(i);
                 Collection endpoints = graph.getEndpoints(e);
    @@ -351,19 +351,19 @@ private void validateFraction(double fraction) {
          * Build a SampleResult by inducing the subgraph on the sampled nodes.
          */
         private SampleResult buildResult(Set sampledNodes, String strategy) {
    -        Graph sample = new UndirectedSparseGraph();
    +        Graph sample = new UndirectedSparseGraph();
             for (String v : sampledNodes) {
                 sample.addVertex(v);
             }
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection endpoints = graph.getEndpoints(e);
                 if (endpoints == null || endpoints.size() < 2) continue;
                 Iterator it = endpoints.iterator();
                 String v1 = it.next();
                 String v2 = it.next();
                 if (sampledNodes.contains(v1) && sampledNodes.contains(v2)) {
    -                edge copy = new edge(e.getType(), v1, v2);
    +                edge copy = new Edge(e.getType(), v1, v2);
                     copy.setWeight(e.getWeight());
                     copy.setLabel(e.getLabel());
                     if (e.getTimestamp() != null) copy.setTimestamp(e.getTimestamp());
    @@ -380,20 +380,20 @@ private SampleResult buildResult(Set sampledNodes, String strategy) {
          * Build a SampleResult from pre-selected edges (for edge sampling).
          */
         private SampleResult buildResultFromEdges(Set sampledNodes,
    -                                              Set sampledEdges,
    +                                              Set sampledEdges,
                                                   String strategy) {
    -        Graph sample = new UndirectedSparseGraph();
    +        Graph sample = new UndirectedSparseGraph();
             for (String v : sampledNodes) {
                 sample.addVertex(v);
             }
     
    -        for (edge e : sampledEdges) {
    +        for (Edge e : sampledEdges) {
                 Collection endpoints = graph.getEndpoints(e);
                 if (endpoints == null || endpoints.size() < 2) continue;
                 Iterator it = endpoints.iterator();
                 String v1 = it.next();
                 String v2 = it.next();
    -            edge copy = new edge(e.getType(), v1, v2);
    +            edge copy = new Edge(e.getType(), v1, v2);
                 copy.setWeight(e.getWeight());
                 copy.setLabel(e.getLabel());
                 if (e.getTimestamp() != null) copy.setTimestamp(e.getTimestamp());
    @@ -403,7 +403,7 @@ private SampleResult buildResultFromEdges(Set sampledNodes,
     
             // Also add any induced edges between sampled nodes that weren't
             // directly selected (edges between endpoints of sampled edges)
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 if (sampledEdges.contains(e)) continue;
                 Collection endpoints = graph.getEndpoints(e);
                 if (endpoints == null || endpoints.size() < 2) continue;
    @@ -412,7 +412,7 @@ private SampleResult buildResultFromEdges(Set sampledNodes,
                 String v2 = it.next();
                 if (sampledNodes.contains(v1) && sampledNodes.contains(v2)
                         && sample.findEdge(v1, v2) == null) {
    -                edge copy = new edge(e.getType(), v1, v2);
    +                edge copy = new Edge(e.getType(), v1, v2);
                     copy.setWeight(e.getWeight());
                     copy.setLabel(e.getLabel());
                     if (e.getTimestamp() != null) copy.setTimestamp(e.getTimestamp());
    @@ -434,7 +434,7 @@ private SampleResult buildResultFromEdges(Set sampledNodes,
          * representativeness metrics, and a summary.
          */
         public static class SampleResult {
    -        private final Graph sample;
    +        private final Graph sample;
             private final int originalNodes;
             private final int originalEdges;
             private final String strategy;
    @@ -444,7 +444,7 @@ public static class SampleResult {
             private final double originalDensity;
             private final int componentCount;
     
    -        SampleResult(Graph sample, int originalNodes,
    +        SampleResult(Graph sample, int originalNodes,
                          int originalEdges, String strategy) {
                 this.sample = sample;
                 this.originalNodes = originalNodes;
    @@ -467,7 +467,7 @@ public static class SampleResult {
             }
     
             /** The sampled subgraph. */
    -        public Graph getSample() { return sample; }
    +        public Graph getSample() { return sample; }
     
             /** Number of nodes in the sample. */
             public int getNodeCount() { return sample.getVertexCount(); }
    diff --git a/Gvisual/src/gvisual/GraphSimilarityAnalyzer.java b/Gvisual/src/gvisual/GraphSimilarityAnalyzer.java
    index d439458..d433779 100644
    --- a/Gvisual/src/gvisual/GraphSimilarityAnalyzer.java
    +++ b/Gvisual/src/gvisual/GraphSimilarityAnalyzer.java
    @@ -41,8 +41,8 @@ public class GraphSimilarityAnalyzer {
         private static final double EPSILON = 1e-12;
         private static final int JACOBI_MAX_SWEEPS = 100;
     
    -    private final Graph graph1;
    -    private final Graph graph2;
    +    private final Graph graph1;
    +    private final Graph graph2;
         private boolean computed;
     
         // ── Results ─────────────────────────────────────────────────────
    @@ -62,8 +62,8 @@ public class GraphSimilarityAnalyzer {
          * @param graph2 the second graph
          * @throws NullPointerException if either graph is null
          */
    -    public GraphSimilarityAnalyzer(Graph graph1,
    -                                    Graph graph2) {
    +    public GraphSimilarityAnalyzer(Graph graph1,
    +                                    Graph graph2) {
             this.graph1 = Objects.requireNonNull(graph1, "graph1 must not be null");
             this.graph2 = Objects.requireNonNull(graph2, "graph2 must not be null");
             this.computed = false;
    @@ -299,7 +299,7 @@ private void ensureComputed() {
         /**
          * Gets the degree probability distribution for a graph.
          */
    -    private Map getDegreeDistribution(Graph g) {
    +    private Map getDegreeDistribution(Graph g) {
             Map freq = new HashMap<>();
             int n = g.getVertexCount();
             if (n == 0) return new HashMap<>();
    @@ -320,7 +320,7 @@ private Map getDegreeDistribution(Graph g) {
         /**
          * Gets sorted Laplacian eigenvalues for a graph.
          */
    -    private double[] getLaplacianEigenvalues(Graph g) {
    +    private double[] getLaplacianEigenvalues(Graph g) {
             int n = g.getVertexCount();
             if (n <= 1) return new double[0];
     
    diff --git a/Gvisual/src/gvisual/GraphSparsificationAnalyzer.java b/Gvisual/src/gvisual/GraphSparsificationAnalyzer.java
    index 7dee229..0f38705 100644
    --- a/Gvisual/src/gvisual/GraphSparsificationAnalyzer.java
    +++ b/Gvisual/src/gvisual/GraphSparsificationAnalyzer.java
    @@ -24,9 +24,9 @@
      */
     public class GraphSparsificationAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
    -    public GraphSparsificationAnalyzer(Graph graph) {
    +    public GraphSparsificationAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -39,7 +39,7 @@ public Map scoreEdgeImportance() {
             if (graph.getEdgeCount() == 0) return scores;
     
             Map betweenness = computeEdgeBetweenness();
    -        Set bridges = findBridges();
    +        Set bridges = findBridges();
     
             double maxBet = 0;
             for (double val : betweenness.values()) {
    @@ -51,7 +51,7 @@ public Map scoreEdgeImportance() {
                 if (graph.degree(vtx) > maxDeg) maxDeg = graph.degree(vtx);
             }
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 double score = 0;
                 if (bridges.contains(e)) score += 0.5;
                 double bet = betweenness.containsKey(e) ? betweenness.get(e) : 0;
    @@ -67,8 +67,8 @@ public Map scoreEdgeImportance() {
         }
     
         /** Finds bridge edges whose removal disconnects the graph. */
    -    public Set findBridges() {
    -        Set bridges = new LinkedHashSet();
    +    public Set findBridges() {
    +        Set bridges = new LinkedHashSet();
             if (graph.getVertexCount() == 0) return bridges;
             Map disc = new HashMap();
             Map low = new HashMap();
    @@ -81,7 +81,7 @@ public Set findBridges() {
         }
     
         private void bridgeDFS(String u, Map disc, Map low,
    -                           Map parent, int[] timer, Set bridges) {
    +                           Map parent, int[] timer, Set bridges) {
             disc.put(u, timer[0]);
             low.put(u, timer[0]);
             timer[0]++;
    @@ -101,23 +101,23 @@ private void bridgeDFS(String u, Map disc, Map
         }
     
         /** Spanning tree (Kruskal's MST). */
    -    public Graph spanningTreeSparsify() {
    -        Graph sparse = new UndirectedSparseGraph();
    +    public Graph spanningTreeSparsify() {
    +        Graph sparse = new UndirectedSparseGraph();
             for (String vtx : graph.getVertices()) sparse.addVertex(vtx);
             if (graph.getVertexCount() <= 1) return sparse;
     
    -        List edges = new ArrayList(graph.getEdges());
    -        Collections.sort(edges, (edge a, edge b) -> { return Float.compare(a.getWeight(), b.getWeight()); });
    +        List edges = new ArrayList(graph.getEdges());
    +        Collections.sort(edges, (Edge a, edge b) -> { return Float.compare(a.getWeight(), b.getWeight()); });
             Map par = new HashMap();
             Map rnk = new HashMap();
             for (String vtx : graph.getVertices()) { par.put(vtx, vtx); rnk.put(vtx, 0); }
     
    -        for (edge e : edges) {
    +        for (Edge e : edges) {
                 String u = e.getVertex1(), vt = e.getVertex2();
                 if (u == null || vt == null) continue;
                 String ru = ufFind(par, u), rv = ufFind(par, vt);
                 if (!ru.equals(rv)) {
    -                edge ne = new edge(e.getType(), u, vt);
    +                edge ne = new Edge(e.getType(), u, vt);
                     ne.setWeight(e.getWeight()); ne.setLabel(e.getLabel());
                     sparse.addEdge(ne, u, vt);
                     ufUnion(par, rnk, ru, rv);
    @@ -137,16 +137,16 @@ private void ufUnion(Map p, Map r, String a, St
         }
     
         /** Random sparsification — keeps each edge with given probability. */
    -    public Graph randomSparsify(double keepProb, long seed) {
    +    public Graph randomSparsify(double keepProb, long seed) {
             if (keepProb < 0 || keepProb > 1) throw new IllegalArgumentException("keepProbability must be between 0 and 1");
    -        Graph sparse = new UndirectedSparseGraph();
    +        Graph sparse = new UndirectedSparseGraph();
             for (String vtx : graph.getVertices()) sparse.addVertex(vtx);
             Random rng = new Random(seed);
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 if (rng.nextDouble() < keepProb) {
                     String u = e.getVertex1(), vt = e.getVertex2();
                     if (u != null && vt != null) {
    -                    edge ne = new edge(e.getType(), u, vt);
    +                    edge ne = new Edge(e.getType(), u, vt);
                         ne.setWeight(e.getWeight()); ne.setLabel(e.getLabel());
                         sparse.addEdge(ne, u, vt);
                     }
    @@ -156,14 +156,14 @@ public Graph randomSparsify(double keepProb, long seed) {
         }
     
         /** Threshold sparsification — keeps edges with weight >= threshold. */
    -    public Graph thresholdSparsify(float threshold) {
    -        Graph sparse = new UndirectedSparseGraph();
    +    public Graph thresholdSparsify(float threshold) {
    +        Graph sparse = new UndirectedSparseGraph();
             for (String vtx : graph.getVertices()) sparse.addVertex(vtx);
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 if (e.getWeight() >= threshold) {
                     String u = e.getVertex1(), vt = e.getVertex2();
                     if (u != null && vt != null) {
    -                    edge ne = new edge(e.getType(), u, vt);
    +                    edge ne = new Edge(e.getType(), u, vt);
                         ne.setWeight(e.getWeight()); ne.setLabel(e.getLabel());
                         sparse.addEdge(ne, u, vt);
                     }
    @@ -173,23 +173,23 @@ public Graph thresholdSparsify(float threshold) {
         }
     
         /** Local sparsification — keep top-k edges per vertex by weight. */
    -    public Graph localSparsify(int k) {
    +    public Graph localSparsify(int k) {
             if (k < 1) throw new IllegalArgumentException("k must be at least 1");
    -        Graph sparse = new UndirectedSparseGraph();
    +        Graph sparse = new UndirectedSparseGraph();
             for (String vtx : graph.getVertices()) sparse.addVertex(vtx);
             Set added = new HashSet();
     
             for (String vertex : graph.getVertices()) {
    -            List inc = new ArrayList(graph.getIncidentEdges(vertex));
    -            Collections.sort(inc, (edge a, edge b) -> { return Float.compare(b.getWeight(), a.getWeight()); });
    +            List inc = new ArrayList(graph.getIncidentEdges(vertex));
    +            Collections.sort(inc, (Edge a, edge b) -> { return Float.compare(b.getWeight(), a.getWeight()); });
                 int cnt = 0;
    -            for (edge e : inc) {
    +            for (Edge e : inc) {
                     if (cnt >= k) break;
                     String u = e.getVertex1(), vt = e.getVertex2();
                     if (u == null || vt == null) continue;
                     String key = u.compareTo(vt) < 0 ? u + "|" + vt : vt + "|" + u;
                     if (!added.contains(key)) {
    -                    edge ne = new edge(e.getType(), u, vt);
    +                    edge ne = new Edge(e.getType(), u, vt);
                         ne.setWeight(e.getWeight()); ne.setLabel(e.getLabel());
                         sparse.addEdge(ne, u, vt);
                         added.add(key);
    @@ -201,9 +201,9 @@ public Graph localSparsify(int k) {
         }
     
         /** Importance-based sparsification — keeps the most important edges. */
    -    public Graph importanceSparsify(double keepRatio) {
    +    public Graph importanceSparsify(double keepRatio) {
             if (keepRatio < 0 || keepRatio > 1) throw new IllegalArgumentException("keepRatio must be between 0 and 1");
    -        Graph sparse = new UndirectedSparseGraph();
    +        Graph sparse = new UndirectedSparseGraph();
             for (String vtx : graph.getVertices()) sparse.addVertex(vtx);
     
             Map scores = scoreEdgeImportance();
    @@ -218,7 +218,7 @@ public Graph importanceSparsify(double keepRatio) {
                 edge e = entry.getKey();
                 String u = e.getVertex1(), vt = e.getVertex2();
                 if (u != null && vt != null) {
    -                edge ne = new edge(e.getType(), u, vt);
    +                edge ne = new Edge(e.getType(), u, vt);
                     ne.setWeight(e.getWeight()); ne.setLabel(e.getLabel());
                     sparse.addEdge(ne, u, vt);
                 }
    @@ -257,7 +257,7 @@ public String getGrade() {
             }
         }
     
    -    public SparsificationQuality evaluateQuality(Graph sparse) {
    +    public SparsificationQuality evaluateQuality(Graph sparse) {
             if (sparse == null) throw new IllegalArgumentException("Sparse graph must not be null");
             int ov = graph.getVertexCount(), oe = graph.getEdgeCount();
             int sv = sparse.getVertexCount(), se = sparse.getEdgeCount();
    @@ -270,11 +270,11 @@ public SparsificationQuality evaluateQuality(Graph sparse) {
             return new SparsificationQuality(ov, oe, sv, se, er, oc == sc, oc, sc, od, sd, ado, ads, degreeCorr(graph, sparse));
         }
     
    -    private int countComponents(Graph g) {
    +    private int countComponents(Graph g) {
             return GraphUtils.findComponents(g).size();
         }
     
    -    private double degreeCorr(Graph g1, Graph g2) {
    +    private double degreeCorr(Graph g1, Graph g2) {
             List common = new ArrayList();
             for (String vtx : g1.getVertices()) { if (g2.containsVertex(vtx)) common.add(vtx); }
             if (common.size() < 2) return 0;
    @@ -294,7 +294,7 @@ private double pearson(double[] x, double[] y) {
     
         private Map computeEdgeBetweenness() {
             Map bet = new LinkedHashMap();
    -        for (edge e : graph.getEdges()) bet.put(e, 0.0);
    +        for (Edge e : graph.getEdges()) bet.put(e, 0.0);
             for (String s : graph.getVertices()) {
                 Stack stack = new Stack();
                 Map> pred = new HashMap>();
    @@ -322,7 +322,7 @@ private Map computeEdgeBetweenness() {
                     }
                 }
             }
    -        for (edge e : bet.keySet()) bet.put(e, bet.get(e) / 2.0);
    +        for (Edge e : bet.keySet()) bet.put(e, bet.get(e) / 2.0);
             return bet;
         }
     
    @@ -392,11 +392,11 @@ public String generateReport() {
             sb.append(String.format("  Bridges:           %d (%.1f%%)\n", sm.bridgeCount, sm.bridgeFraction * 100));
             sb.append("\n");
     
    -        Set bridges = findBridges();
    +        Set bridges = findBridges();
             if (!bridges.isEmpty()) {
                 sb.append("── Bridge Edges (critical) ──\n");
                 int cnt = 0;
    -            for (edge e : bridges) {
    +            for (Edge e : bridges) {
                     if (cnt >= 10) { sb.append(String.format("  ... and %d more\n", bridges.size() - 10)); break; }
                     sb.append(String.format("  %s — %s\n", e.getVertex1(), e.getVertex2()));
                     cnt++;
    diff --git a/Gvisual/src/gvisual/GraphStats.java b/Gvisual/src/gvisual/GraphStats.java
    index 93e4113..76202bf 100644
    --- a/Gvisual/src/gvisual/GraphStats.java
    +++ b/Gvisual/src/gvisual/GraphStats.java
    @@ -12,12 +12,12 @@
      */
     public class GraphStats {
     
    -    private final Graph graph;
    -    private final List friendEdges;
    -    private final List fsEdges;
    -    private final List classmateEdges;
    -    private final List strangerEdges;
    -    private final List studyGEdges;
    +    private final Graph graph;
    +    private final List friendEdges;
    +    private final List fsEdges;
    +    private final List classmateEdges;
    +    private final List strangerEdges;
    +    private final List studyGEdges;
     
         /**
          * @param graph         the current JUNG graph
    @@ -27,12 +27,12 @@ public class GraphStats {
          * @param strangerEdges stranger edges
          * @param studyGEdges   study group edges
          */
    -    public GraphStats(Graph graph,
    -                      List friendEdges,
    -                      List fsEdges,
    -                      List classmateEdges,
    -                      List strangerEdges,
    -                      List studyGEdges) {
    +    public GraphStats(Graph graph,
    +                      List friendEdges,
    +                      List fsEdges,
    +                      List classmateEdges,
    +                      List strangerEdges,
    +                      List studyGEdges) {
             this.graph = graph;
             this.friendEdges = friendEdges;
             this.fsEdges = fsEdges;
    @@ -201,7 +201,7 @@ public double getAverageWeight() {
             if (graph.getEdgeCount() == 0) return 0.0;
             if (cachedTotalWeight < 0) {
                 cachedTotalWeight = 0;
    -            for (edge e : graph.getEdges()) {
    +            for (Edge e : graph.getEdges()) {
                     cachedTotalWeight += e.getWeight();
                 }
             }
    diff --git a/Gvisual/src/gvisual/GraphSummarizer.java b/Gvisual/src/gvisual/GraphSummarizer.java
    index 84ce57f..dd8ae00 100644
    --- a/Gvisual/src/gvisual/GraphSummarizer.java
    +++ b/Gvisual/src/gvisual/GraphSummarizer.java
    @@ -25,14 +25,14 @@
      */
     public class GraphSummarizer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private final GraphStats stats;
         private final CommunityDetector communities;
    -    private final List friendEdges;
    -    private final List fsEdges;
    -    private final List classmateEdges;
    -    private final List strangerEdges;
    -    private final List studyGEdges;
    +    private final List friendEdges;
    +    private final List fsEdges;
    +    private final List classmateEdges;
    +    private final List strangerEdges;
    +    private final List studyGEdges;
     
         /**
          * Creates a new GraphSummarizer.
    @@ -45,21 +45,21 @@ public class GraphSummarizer {
          * @param studyGEdges    study group edges
          * @throws IllegalArgumentException if graph is null
          */
    -    public GraphSummarizer(Graph graph,
    -                           List friendEdges,
    -                           List fsEdges,
    -                           List classmateEdges,
    -                           List strangerEdges,
    -                           List studyGEdges) {
    +    public GraphSummarizer(Graph graph,
    +                           List friendEdges,
    +                           List fsEdges,
    +                           List classmateEdges,
    +                           List strangerEdges,
    +                           List studyGEdges) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
             this.graph = graph;
    -        this.friendEdges = friendEdges != null ? friendEdges : new ArrayList();
    -        this.fsEdges = fsEdges != null ? fsEdges : new ArrayList();
    -        this.classmateEdges = classmateEdges != null ? classmateEdges : new ArrayList();
    -        this.strangerEdges = strangerEdges != null ? strangerEdges : new ArrayList();
    -        this.studyGEdges = studyGEdges != null ? studyGEdges : new ArrayList();
    +        this.friendEdges = friendEdges != null ? friendEdges : new ArrayList();
    +        this.fsEdges = fsEdges != null ? fsEdges : new ArrayList();
    +        this.classmateEdges = classmateEdges != null ? classmateEdges : new ArrayList();
    +        this.strangerEdges = strangerEdges != null ? strangerEdges : new ArrayList();
    +        this.studyGEdges = studyGEdges != null ? studyGEdges : new ArrayList();
             this.stats = new GraphStats(graph, this.friendEdges, this.fsEdges,
                     this.classmateEdges, this.strangerEdges, this.studyGEdges);
             this.communities = new CommunityDetector(graph);
    diff --git a/Gvisual/src/gvisual/GraphSymmetryAnalyzer.java b/Gvisual/src/gvisual/GraphSymmetryAnalyzer.java
    index e6371f1..6357872 100644
    --- a/Gvisual/src/gvisual/GraphSymmetryAnalyzer.java
    +++ b/Gvisual/src/gvisual/GraphSymmetryAnalyzer.java
    @@ -39,16 +39,16 @@
      */
     public class GraphSymmetryAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /** Lazily computed colour-refinement partition (vertex → orbit id). */
         private Map vertexOrbitMap;
         /** Lazily computed orbit groups. */
         private List> orbits;
         /** Lazily computed edge orbits. */
    -    private List> edgeOrbits;
    +    private List> edgeOrbits;
     
    -    public GraphSymmetryAnalyzer(Graph graph) {
    +    public GraphSymmetryAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -151,8 +151,8 @@ private void ensureComputed() {
     
             // Build edge orbits: two edges are equivalent if their endpoint
             // orbit-pair (sorted) is identical
    -        Map, Set> edgeGroups = new LinkedHashMap<>();
    -        for (edge e : graph.getEdges()) {
    +        Map, Set> edgeGroups = new LinkedHashMap<>();
    +        for (Edge e : graph.getEdges()) {
                 String v1 = e.getVertex1();
                 String v2 = e.getVertex2();
                 int o1 = vertexOrbitMap.getOrDefault(v1, -1);
    @@ -216,7 +216,7 @@ public Set getOrbitOf(String vertex) {
          * Returns the list of edge orbits. Edges whose endpoint orbit-pairs
          * match are grouped together.
          */
    -    public List> getEdgeOrbits() {
    +    public List> getEdgeOrbits() {
             ensureComputed();
             return Collections.unmodifiableList(edgeOrbits);
         }
    diff --git a/Gvisual/src/gvisual/GraphTimelineExporter.java b/Gvisual/src/gvisual/GraphTimelineExporter.java
    index 98fd979..d96e9e0 100644
    --- a/Gvisual/src/gvisual/GraphTimelineExporter.java
    +++ b/Gvisual/src/gvisual/GraphTimelineExporter.java
    @@ -91,7 +91,7 @@ public String exportToString() {
             // Build snapshot data for each time point
             List> snapshots = new ArrayList<>();
             for (Long t : timePoints) {
    -            Graph snap = temporalGraph.snapshotAt(t);
    +            Graph snap = temporalGraph.snapshotAt(t);
                 Map s = new LinkedHashMap<>();
                 s.put("time", t);
     
    @@ -105,7 +105,7 @@ public String exportToString() {
                 s.put("nodes", nodes);
     
                 List> edges = new ArrayList<>();
    -            for (edge e : snap.getEdges()) {
    +            for (Edge e : snap.getEdges()) {
                     Map ed = new LinkedHashMap<>();
                     ed.put("source", e.getVertex1());
                     ed.put("target", e.getVertex2());
    @@ -124,7 +124,7 @@ public String exportToString() {
             for (int i = 0; i < timePoints.size(); i++) {
                 long tEnd = timePoints.get(i);
                 long tStart = timePoints.get(0);
    -            Graph cumSnap = temporalGraph.windowBetween(tStart, tEnd);
    +            Graph cumSnap = temporalGraph.windowBetween(tStart, tEnd);
                 Map s = new LinkedHashMap<>();
                 s.put("time", tEnd);
     
    @@ -138,7 +138,7 @@ public String exportToString() {
                 s.put("nodes", nodes);
     
                 List> edges = new ArrayList<>();
    -            for (edge e : cumSnap.getEdges()) {
    +            for (Edge e : cumSnap.getEdges()) {
                     Map ed = new LinkedHashMap<>();
                     ed.put("source", e.getVertex1());
                     ed.put("target", e.getVertex2());
    diff --git a/Gvisual/src/gvisual/GraphUtils.java b/Gvisual/src/gvisual/GraphUtils.java
    index 0622f95..38637b3 100644
    --- a/Gvisual/src/gvisual/GraphUtils.java
    +++ b/Gvisual/src/gvisual/GraphUtils.java
    @@ -29,7 +29,7 @@ private GraphUtils() { /* utility class */ }
          * @return the other endpoint, or {@code null} if {@code current} is not
          *         an endpoint of the edge
          */
    -    public static String getOtherEnd(edge e, String current) {
    +    public static String getOtherEnd(Edge e, String current) {
             String v1 = e.getVertex1();
             String v2 = e.getVertex2();
             if (current.equals(v1)) return v2;
    @@ -44,7 +44,7 @@ public static String getOtherEnd(edge e, String current) {
          * @return map from each vertex to its set of neighbor vertex IDs
          */
         public static Map> buildAdjacencyMap(
    -            Graph graph) {
    +            Graph graph) {
             Map> adj = new HashMap>();
             for (String v : graph.getVertices()) {
                 Set neighbors = new HashSet();
    @@ -66,12 +66,12 @@ public static Map> buildAdjacencyMap(
          * @return adjacency map (vertex → set of neighbours within the subset)
          */
         public static Map> buildAdjacencyMap(
    -            Graph graph, Set vertices) {
    +            Graph graph, Set vertices) {
             Map> adj = new HashMap>();
             for (String v : vertices) {
                 adj.put(v, new HashSet());
             }
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection eps = graph.getEndpoints(e);
                 if (eps == null || eps.size() != 2) continue;
                 Iterator it = eps.iterator();
    @@ -94,7 +94,7 @@ public static Map> buildAdjacencyMap(
          * @return map from vertex ID to its BFS distance from source
          */
         public static Map bfsDistances(
    -            Graph graph, String source) {
    +            Graph graph, String source) {
             Map distances = new HashMap();
             Queue queue = new LinkedList();
             distances.put(source, 0);
    @@ -103,9 +103,9 @@ public static Map bfsDistances(
             while (!queue.isEmpty()) {
                 String current = queue.poll();
                 int currentDist = distances.get(current);
    -            Collection incidentEdges = graph.getIncidentEdges(current);
    +            Collection incidentEdges = graph.getIncidentEdges(current);
                 if (incidentEdges == null) continue;
    -            for (edge e : incidentEdges) {
    +            for (Edge e : incidentEdges) {
                     String neighbor = getOtherEnd(e, current);
                     if (neighbor != null && !distances.containsKey(neighbor)) {
                         distances.put(neighbor, currentDist + 1);
    @@ -124,7 +124,7 @@ public static Map bfsDistances(
          * @return set of all vertices reachable from source (including source)
          */
         public static Set bfsComponent(
    -            Graph graph, String source) {
    +            Graph graph, String source) {
             Set component = new LinkedHashSet();
             Queue queue = new LinkedList();
             component.add(source);
    @@ -132,9 +132,9 @@ public static Set bfsComponent(
     
             while (!queue.isEmpty()) {
                 String current = queue.poll();
    -            Collection incidentEdges = graph.getIncidentEdges(current);
    +            Collection incidentEdges = graph.getIncidentEdges(current);
                 if (incidentEdges == null) continue;
    -            for (edge e : incidentEdges) {
    +            for (Edge e : incidentEdges) {
                     String neighbor = getOtherEnd(e, current);
                     if (neighbor != null && !component.contains(neighbor)) {
                         component.add(neighbor);
    @@ -152,7 +152,7 @@ public static Set bfsComponent(
          * @return list of components, each a set of vertex IDs, sorted largest-first
          */
         public static List> findComponents(
    -            Graph graph) {
    +            Graph graph) {
             Set visited = new HashSet();
             List> components = new ArrayList>();
     
    @@ -178,7 +178,7 @@ public static List> findComponents(
          * @return set of vertices in the largest component, or empty set if graph is empty
          */
         public static Set findLargestComponent(
    -            Graph graph) {
    +            Graph graph) {
             List> components = findComponents(graph);
             return components.isEmpty() ? Collections.emptySet() : components.get(0);
         }
    @@ -213,7 +213,7 @@ public static Set getCommonNeighbors(
          * @return true if the induced subgraph contains a cycle
          */
         public static boolean hasCycleInSubgraph(
    -            Graph graph, Set vertices, boolean directed) {
    +            Graph graph, Set vertices, boolean directed) {
             if (vertices.size() <= 1) return false;
             Set visited = new HashSet();
             Set inStack = new HashSet();
    @@ -230,7 +230,7 @@ public static boolean hasCycleInSubgraph(
         }
     
         private static boolean hasCycleDFS_undirected(
    -            Graph graph, String v, String parent,
    +            Graph graph, String v, String parent,
                 Set vertices, Set visited) {
             visited.add(v);
             for (String n : graph.getNeighbors(v)) {
    @@ -245,7 +245,7 @@ private static boolean hasCycleDFS_undirected(
         }
     
         private static boolean hasCycleDFS_directed(
    -            Graph graph, String v, Set vertices,
    +            Graph graph, String v, Set vertices,
                 Set visited, Set inStack) {
             visited.add(v);
             inStack.add(v);
    @@ -269,11 +269,11 @@ private static boolean hasCycleDFS_directed(
          * @return number of edges where both endpoints are in the vertex set
          */
         public static int countEdgesInSubgraph(
    -            Graph graph, Set vertices) {
    +            Graph graph, Set vertices) {
             int count = 0;
    -        Set seen = new HashSet();
    +        Set seen = new HashSet();
             for (String v : vertices) {
    -            for (edge e : graph.getIncidentEdges(v)) {
    +            for (Edge e : graph.getIncidentEdges(v)) {
                     if (seen.contains(e)) continue;
                     boolean allIn = true;
                     for (String ep : graph.getEndpoints(e)) {
    @@ -293,7 +293,7 @@ public static int countEdgesInSubgraph(
          * @return number of connected components within the subset
          */
         public static int countComponentsInSubgraph(
    -            Graph graph, Set vertices) {
    +            Graph graph, Set vertices) {
             Set visited = new HashSet();
             int components = 0;
             for (String v : vertices) {
    @@ -325,7 +325,7 @@ public static int countComponentsInSubgraph(
          * @return the cycle rank of the induced subgraph
          */
         public static int cycleRankOfSubgraph(
    -            Graph graph, Set vertices) {
    +            Graph graph, Set vertices) {
             int edges = countEdgesInSubgraph(graph, vertices);
             int comps = countComponentsInSubgraph(graph, vertices);
             return edges - vertices.size() + comps;
    @@ -340,17 +340,17 @@ public static int cycleRankOfSubgraph(
          * @param graph the graph to copy
          * @return a new graph with identical structure
          */
    -    public static Graph copyGraph(Graph graph) {
    -        Graph copy = new UndirectedSparseGraph();
    +    public static Graph copyGraph(Graph graph) {
    +        Graph copy = new UndirectedSparseGraph();
             for (String v : graph.getVertices()) {
                 copy.addVertex(v);
             }
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection endpoints = graph.getEndpoints(e);
                 Iterator it = endpoints.iterator();
                 String v1 = it.next();
                 String v2 = it.next();
    -            edge newEdge = new edge(e.getType(), v1, v2);
    +            edge newEdge = new Edge(e.getType(), v1, v2);
                 newEdge.setWeight(e.getWeight());
                 newEdge.setLabel(e.getLabel());
                 copy.addEdge(newEdge, v1, v2);
    @@ -372,7 +372,7 @@ public static Graph copyGraph(Graph graph) {
          * @param graph the graph
          * @return map from vertex ID to betweenness centrality score
          */
    -    public static Map computeBetweenness(Graph graph) {
    +    public static Map computeBetweenness(Graph graph) {
             int n = graph.getVertexCount();
             if (n == 0) return Collections.emptyMap();
     
    @@ -477,7 +477,7 @@ public static Map computeBetweenness(Graph graph)
          * @param graph the graph
          * @return global efficiency in [0, 1]
          */
    -    public static double globalEfficiency(Graph graph) {
    +    public static double globalEfficiency(Graph graph) {
             int n = graph.getVertexCount();
             if (n <= 1) return 0.0;
     
    @@ -568,7 +568,7 @@ public DijkstraResult(Map dist, Map prev) {
          * @param source the source vertex
          * @return distances and predecessors for all reachable vertices
          */
    -    public static DijkstraResult dijkstra(Graph graph, String source) {
    +    public static DijkstraResult dijkstra(Graph graph, String source) {
             Map dist = new HashMap();
             Map prev = new HashMap();
             Set visited = new HashSet();
    @@ -599,7 +599,7 @@ public static DijkstraResult dijkstra(Graph graph, String source)
                 Double uDist = dist.get(u);
                 if (uDist == null || entryDist > uDist) continue;
     
    -            for (edge e : graph.getIncidentEdges(u)) {
    +            for (Edge e : graph.getIncidentEdges(u)) {
                     String v = getOtherEnd(e, u);
                     if (v == null || visited.contains(v)) continue;
     
    @@ -660,7 +660,7 @@ public static List reconstructPath(
          * @return neighbors of v, or an empty collection if null
          */
         public static Collection neighborsOf(
    -            Graph graph, String v) {
    +            Graph graph, String v) {
             Collection nbrs = graph.getNeighbors(v);
             return nbrs != null ? nbrs : Collections.emptyList();
         }
    @@ -697,7 +697,7 @@ public DirectedAdj(Set vertices,
          * @return a {@link DirectedAdj} with successor and predecessor maps
          */
         public static DirectedAdj buildDirectedAdjacencyMap(
    -            Graph graph) {
    +            Graph graph) {
             Map> successors = new HashMap>();
             Map> predecessors = new HashMap>();
             Set allVertices = new HashSet();
    @@ -708,7 +708,7 @@ public static DirectedAdj buildDirectedAdjacencyMap(
                 predecessors.put(v, new HashSet());
             }
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String from = e.getVertex1();
                 String to = e.getVertex2();
                 if (from != null && to != null
    diff --git a/Gvisual/src/gvisual/GrowthRateAnalyzer.java b/Gvisual/src/gvisual/GrowthRateAnalyzer.java
    index c9cd723..e00ed31 100644
    --- a/Gvisual/src/gvisual/GrowthRateAnalyzer.java
    +++ b/Gvisual/src/gvisual/GrowthRateAnalyzer.java
    @@ -66,12 +66,12 @@ public GrowthRateAnalyzer(TemporalGraph temporalGraph, int windowCount) {
          * @return ordered list of metric snapshots
          */
         public List analyze() {
    -        List>> windows =
    +        List>> windows =
                 temporalGraph.generateWindows(windowCount);
     
             List snapshots = new ArrayList<>();
    -        for (Map.Entry> window : windows) {
    -            Graph g = window.getValue();
    +        for (Map.Entry> window : windows) {
    +            Graph g = window.getValue();
                 int nodes = g.getVertexCount();
                 int edges = g.getEdgeCount();
                 double density = computeDensity(nodes, edges);
    @@ -115,7 +115,7 @@ private static double computeDensity(int nodes, int edges) {
             return edges / maxEdges;
         }
     
    -    private static double computeAvgClustering(Graph g) {
    +    private static double computeAvgClustering(Graph g) {
             if (g.getVertexCount() == 0) return 0.0;
     
             Map> adj = GraphUtils.buildAdjacencyMap(g);
    diff --git a/Gvisual/src/gvisual/HierarchicalLayout.java b/Gvisual/src/gvisual/HierarchicalLayout.java
    index 2502c94..5f89c98 100644
    --- a/Gvisual/src/gvisual/HierarchicalLayout.java
    +++ b/Gvisual/src/gvisual/HierarchicalLayout.java
    @@ -55,7 +55,7 @@ public enum Orientation {
     
         // ── Configuration ────────────────────────────────────────────────
     
    -    private final Graph graph;
    +    private final Graph graph;
         private final double layerSpacing;
         private final double nodeSpacing;
         private final int crossingSweeps;
    @@ -70,7 +70,7 @@ public enum Orientation {
         private List> layers;
         private List criticalPath;
         private int crossingCount;
    -    private Set reversedEdges;
    +    private Set reversedEdges;
         private boolean computed;
     
         // ── Constructors ─────────────────────────────────────────────────
    @@ -81,7 +81,7 @@ public enum Orientation {
          * @param graph the JUNG graph to lay out
          * @throws IllegalArgumentException if graph is null
          */
    -    public HierarchicalLayout(Graph graph) {
    +    public HierarchicalLayout(Graph graph) {
             this(graph, 120, 80, 24, Orientation.TOP_TO_BOTTOM, 1200, 800);
         }
     
    @@ -97,7 +97,7 @@ public HierarchicalLayout(Graph graph) {
          * @param height         canvas height
          * @throws IllegalArgumentException if parameters are invalid
          */
    -    public HierarchicalLayout(Graph graph, double layerSpacing,
    +    public HierarchicalLayout(Graph graph, double layerSpacing,
                                    double nodeSpacing, int crossingSweeps,
                                    Orientation orientation,
                                    double width, double height) {
    @@ -147,7 +147,7 @@ public HierarchicalLayout compute() {
                 layers = new ArrayList>();
                 criticalPath = new ArrayList();
                 crossingCount = 0;
    -            reversedEdges = new HashSet();
    +            reversedEdges = new HashSet();
                 computed = true;
                 return this;
             }
    @@ -159,7 +159,7 @@ public HierarchicalLayout compute() {
                 successors.put(v, new HashSet());
                 predecessors.put(v, new HashSet());
             }
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String u = e.getVertex1();
                 String v = e.getVertex2();
                 if (u != null && v != null && !u.equals(v)
    @@ -170,7 +170,7 @@ public HierarchicalLayout compute() {
             }
     
             // Step 1: Cycle removal (greedy DFS-based)
    -        reversedEdges = new HashSet();
    +        reversedEdges = new HashSet();
             Map> dagSuccessors = removeCycles(
                     vertices, successors, predecessors);
             Map> dagPredecessors = invertAdjacency(
    @@ -239,7 +239,7 @@ private Map> removeCycles(
                 dag.get(be[1]).add(be[0]);
     
                 // Track the original edge objects
    -            for (edge e : graph.getEdges()) {
    +            for (Edge e : graph.getEdges()) {
                     if (be[0].equals(e.getVertex1()) && be[1].equals(e.getVertex2())) {
                         reversedEdges.add(e);
                     }
    @@ -645,7 +645,7 @@ public int getEdgeCrossings() {
          * @return set of edge objects that were reversed
          * @throws IllegalStateException if compute() has not been called
          */
    -    public Set getReversedEdges() {
    +    public Set getReversedEdges() {
             ensureComputed();
             return Collections.unmodifiableSet(reversedEdges);
         }
    @@ -761,7 +761,7 @@ public String toSVG(int svgWidth, int svgHeight, int nodeRadius) {
             sb.append("  \n");
     
             // Draw edges
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String u = e.getVertex1();
                 String v = e.getVertex2();
                 if (u == null || v == null) continue;
    diff --git a/Gvisual/src/gvisual/IndependentSetAnalyzer.java b/Gvisual/src/gvisual/IndependentSetAnalyzer.java
    index 031918b..fe400d9 100644
    --- a/Gvisual/src/gvisual/IndependentSetAnalyzer.java
    +++ b/Gvisual/src/gvisual/IndependentSetAnalyzer.java
    @@ -35,7 +35,7 @@
      */
     public class IndependentSetAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /**
          * Constructs an analyzer for the given undirected graph.
    @@ -43,7 +43,7 @@ public class IndependentSetAnalyzer {
          * @param graph the graph to analyze (should be undirected)
          * @throws IllegalArgumentException if graph is null
          */
    -    public IndependentSetAnalyzer(Graph graph) {
    +    public IndependentSetAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -536,15 +536,15 @@ public Map vertexIndependenceImpact() {
             Map impact = new LinkedHashMap<>();
             for (String v : graph.getVertices()) {
                 // Build subgraph without v
    -            Graph sub = new UndirectedSparseGraph<>();
    +            Graph sub = new UndirectedSparseGraph<>();
                 for (String u : graph.getVertices()) {
                     if (!u.equals(v)) sub.addVertex(u);
                 }
    -            for (edge e : graph.getEdges()) {
    +            for (Edge e : graph.getEdges()) {
                     String v1 = graph.getEndpoints(e).getFirst();
                     String v2 = graph.getEndpoints(e).getSecond();
                     if (!v1.equals(v) && !v2.equals(v)) {
    -                    sub.addEdge(new edge(e.getType(), v1, v2), v1, v2);
    +                    sub.addEdge(new Edge(e.getType(), v1, v2), v1, v2);
                     }
                 }
                 IndependentSetAnalyzer subAnalyzer = new IndependentSetAnalyzer(sub);
    @@ -610,13 +610,13 @@ public int[] independencePolynomial() {
          * @return the maximum clique (independent set of complement)
          */
         public Set maximumCliqueViaComplement() {
    -        Graph complement = buildComplement();
    +        Graph complement = buildComplement();
             IndependentSetAnalyzer compAnalyzer = new IndependentSetAnalyzer(complement);
             return compAnalyzer.exactMaximumIndependentSet();
         }
     
    -    private Graph buildComplement() {
    -        Graph comp = new UndirectedSparseGraph<>();
    +    private Graph buildComplement() {
    +        Graph comp = new UndirectedSparseGraph<>();
             List vertices = new ArrayList<>(graph.getVertices());
             for (String v : vertices) comp.addVertex(v);
             int edgeId = 0;
    @@ -624,7 +624,7 @@ private Graph buildComplement() {
                 for (int j = i + 1; j < vertices.size(); j++) {
                     String u = vertices.get(i), w = vertices.get(j);
                     if (graph.findEdge(u, w) == null) {
    -                    comp.addEdge(new edge("comp_" + (edgeId++), u, w), u, w);
    +                    comp.addEdge(new Edge("comp_" + (edgeId++), u, w), u, w);
                     }
                 }
             }
    diff --git a/Gvisual/src/gvisual/InfluenceSpreadSimulator.java b/Gvisual/src/gvisual/InfluenceSpreadSimulator.java
    index cb41f6d..38067a1 100644
    --- a/Gvisual/src/gvisual/InfluenceSpreadSimulator.java
    +++ b/Gvisual/src/gvisual/InfluenceSpreadSimulator.java
    @@ -45,7 +45,7 @@ public enum NodeState {
             RECOVERED
         }
     
    -    private final Graph graph;
    +    private final Graph graph;
         private final Random random;
     
         /**
    @@ -71,7 +71,7 @@ public enum NodeState {
          */
         private final Map> predecessorCache;
     
    -    public InfluenceSpreadSimulator(Graph graph) {
    +    public InfluenceSpreadSimulator(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -82,7 +82,7 @@ public InfluenceSpreadSimulator(Graph graph) {
             this.predecessorCache = buildPredecessorCache();
         }
     
    -    public InfluenceSpreadSimulator(Graph graph, long seed) {
    +    public InfluenceSpreadSimulator(Graph graph, long seed) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -119,7 +119,7 @@ private Map> buildNeighborCache() {
          */
         private Map buildEdgeWeightCache() {
             Map cache = new HashMap();
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 double w = e.getWeight();
                 if (w > 0 && w <= 1.0) {
                     Collection endpoints = graph.getEndpoints(e);
    @@ -153,7 +153,7 @@ private Map> buildPredecessorCache() {
                 // Undirected: predecessors == neighbors
                 return neighborCache;
             }
    -        DirectedGraph dg = (DirectedGraph) graph;
    +        DirectedGraph dg = (DirectedGraph) graph;
             Map> cache = new HashMap>();
             for (String node : graph.getVertices()) {
                 Collection preds = dg.getPredecessors(node);
    @@ -486,7 +486,7 @@ public VaccinationStrategy findVaccinationTargets(int k) {
             // of its endpoints is a vaccination target. Counting by degree
             // double-counts edges where both endpoints are vaccinated.
             int totalEdgesBlocked = 0;
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection endpoints = graph.getEndpoints(e);
                 boolean blocked = false;
                 for (String ep : endpoints) {
    diff --git a/Gvisual/src/gvisual/InteractiveHtmlExporter.java b/Gvisual/src/gvisual/InteractiveHtmlExporter.java
    index 8bd7d9a..efc64df 100644
    --- a/Gvisual/src/gvisual/InteractiveHtmlExporter.java
    +++ b/Gvisual/src/gvisual/InteractiveHtmlExporter.java
    @@ -37,7 +37,7 @@
      */
     public class InteractiveHtmlExporter {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private String title = "Graph Visualization";
         private String description = "";
         private boolean showStats = true;
    @@ -51,7 +51,7 @@ public class InteractiveHtmlExporter {
          * Creates an exporter for the given graph.
          * @param graph the JUNG graph to visualize
          */
    -    public InteractiveHtmlExporter(Graph graph) {
    +    public InteractiveHtmlExporter(Graph graph) {
             if (graph == null) throw new IllegalArgumentException("Graph must not be null");
             this.graph = graph;
         }
    @@ -98,7 +98,7 @@ public String exportToString() {
             List edgeList = new ArrayList<>();
             List edgeTypes = new ArrayList<>();
             List edgeWeights = new ArrayList<>();
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String v1 = e.getVertex1();
                 String v2 = e.getVertex2();
                 if (v1 != null && v2 != null && nodeIndex.containsKey(v1) && nodeIndex.containsKey(v2)) {
    diff --git a/Gvisual/src/gvisual/JsonGraphExporter.java b/Gvisual/src/gvisual/JsonGraphExporter.java
    index a16b2da..cf1ac51 100644
    --- a/Gvisual/src/gvisual/JsonGraphExporter.java
    +++ b/Gvisual/src/gvisual/JsonGraphExporter.java
    @@ -35,8 +35,8 @@
      */
     public class JsonGraphExporter {
     
    -    private final Graph graph;
    -    private final List allEdges;
    +    private final Graph graph;
    +    private final List allEdges;
         private String timestamp;
         private String description;
         private boolean prettyPrint;
    @@ -48,12 +48,12 @@ public class JsonGraphExporter {
          * @param graph    the JUNG graph to export
          * @param allEdges all edges (including those not currently visible)
          */
    -    public JsonGraphExporter(Graph graph, List allEdges) {
    +    public JsonGraphExporter(Graph graph, List allEdges) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
             this.graph = graph;
    -        this.allEdges = (allEdges != null) ? allEdges : new ArrayList();
    +        this.allEdges = (allEdges != null) ? allEdges : new ArrayList();
             this.timestamp = "";
             this.description = "";
             this.prettyPrint = true;
    @@ -93,7 +93,7 @@ public String exportToString() {
             String sep = prettyPrint ? " " : "";
     
             Collection vertices = graph.getVertices();
    -        Collection edges = graph.getEdges();
    +        Collection edges = graph.getEdges();
     
             sb.append("{").append(nl);
     
    @@ -151,7 +151,7 @@ public String exportToString() {
                 }
                 // Count edges by type for this node
                 Map typeCounts = new TreeMap();
    -            for (edge e : graph.getIncidentEdges(v)) {
    +            for (Edge e : graph.getIncidentEdges(v)) {
                     String type = e.getType() != null ? e.getType() : "unknown";
                     typeCounts.put(type, typeCounts.containsKey(type) ? typeCounts.get(type) + 1 : 1);
                 }
    @@ -173,7 +173,7 @@ public String exportToString() {
     
             // Links
             sb.append(indent).append("\"links\":").append(sep).append("[").append(nl);
    -        List sortedEdges = new ArrayList(edges);
    +        List sortedEdges = new ArrayList(edges);
             for (int i = 0; i < sortedEdges.size(); i++) {
                 edge e = sortedEdges.get(i);
                 sb.append(indent2).append("{");
    diff --git a/Gvisual/src/gvisual/KCoreDecomposition.java b/Gvisual/src/gvisual/KCoreDecomposition.java
    index 1a18044..9e38d08 100644
    --- a/Gvisual/src/gvisual/KCoreDecomposition.java
    +++ b/Gvisual/src/gvisual/KCoreDecomposition.java
    @@ -40,7 +40,7 @@
      */
     public class KCoreDecomposition {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private Map coreness;
         private int degeneracy;
         private boolean computed;
    @@ -51,7 +51,7 @@ public class KCoreDecomposition {
          * @param graph the JUNG graph to decompose
          * @throws IllegalArgumentException if graph is null
          */
    -    public KCoreDecomposition(Graph graph) {
    +    public KCoreDecomposition(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -317,7 +317,7 @@ public List getCoreDensityProfile() {
     
                 // Count edges within the k-core
                 int edgeCount = 0;
    -            for (edge e : graph.getEdges()) {
    +            for (Edge e : graph.getEdges()) {
                     String v1 = graph.getEndpoints(e).getFirst();
                     String v2 = graph.getEndpoints(e).getSecond();
                     if (coreVertices.contains(v1) && coreVertices.contains(v2)) {
    diff --git a/Gvisual/src/gvisual/KTrussAnalyzer.java b/Gvisual/src/gvisual/KTrussAnalyzer.java
    index 227c81c..980d5f4 100644
    --- a/Gvisual/src/gvisual/KTrussAnalyzer.java
    +++ b/Gvisual/src/gvisual/KTrussAnalyzer.java
    @@ -37,7 +37,7 @@
      */
     public class KTrussAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private Map trussNumbers;
         private Map triangleSupport;
         private int maxTrussNumber;
    @@ -48,7 +48,7 @@ public class KTrussAnalyzer {
          *
          * @param graph the graph to analyze (treated as undirected)
          */
    -    public KTrussAnalyzer(Graph graph) {
    +    public KTrussAnalyzer(Graph graph) {
             this.graph = graph;
             this.trussNumbers = new LinkedHashMap<>();
             this.triangleSupport = new LinkedHashMap<>();
    @@ -70,18 +70,18 @@ private void ensureComputed() {
          */
         private void compute() {
             // Build adjacency structures for efficient triangle enumeration
    -        Set remainingEdges = new LinkedHashSet<>(graph.getEdges());
    +        Set remainingEdges = new LinkedHashSet<>(graph.getEdges());
             Map> adjacency = buildAdjacency(remainingEdges);
    -        Map> edgeTrianglePartners = new LinkedHashMap<>();
    +        Map> edgeTrianglePartners = new LinkedHashMap<>();
     
             // Step 1: compute initial triangle support for each edge
    -        for (edge e : remainingEdges) {
    +        for (Edge e : remainingEdges) {
                 triangleSupport.put(e, 0);
                 edgeTrianglePartners.put(e, new LinkedHashSet<>());
             }
     
             // Find all triangles
    -        for (edge e : remainingEdges) {
    +        for (Edge e : remainingEdges) {
                 String u = getEndpoint1(e);
                 String v = getEndpoint2(e);
                 if (u == null || v == null) continue;
    @@ -113,12 +113,12 @@ private void compute() {
             // but each edge in a triangle gets counted twice for neighbors
             // Actually, let me recalculate properly using a direct approach
             triangleSupport.clear();
    -        for (edge e : remainingEdges) {
    +        for (Edge e : remainingEdges) {
                 triangleSupport.put(e, 0);
             }
     
             // Enumerate triangles properly: for each edge (u,v), count common neighbors
    -        for (edge e : remainingEdges) {
    +        for (Edge e : remainingEdges) {
                 String u = getEndpoint1(e);
                 String v = getEndpoint2(e);
                 if (u == null || v == null) continue;
    @@ -136,7 +136,7 @@ private void compute() {
             }
     
             // Step 2: Peeling — iteratively remove edges with lowest support
    -        Set active = new LinkedHashSet<>(remainingEdges);
    +        Set active = new LinkedHashSet<>(remainingEdges);
             Map support = new LinkedHashMap<>(triangleSupport);
     
             int k = 2;
    @@ -145,7 +145,7 @@ private void compute() {
                 while (changed) {
                     changed = false;
                     Iterator it = active.iterator();
    -                List toRemove = new ArrayList<>();
    +                List toRemove = new ArrayList<>();
     
                     while (it.hasNext()) {
                         edge e = it.next();
    @@ -154,7 +154,7 @@ private void compute() {
                         }
                     }
     
    -                for (edge e : toRemove) {
    +                for (Edge e : toRemove) {
                         active.remove(e);
                         trussNumbers.put(e, k);
                         changed = true;
    @@ -164,7 +164,7 @@ private void compute() {
                         String v = getEndpoint2(e);
                         if (u == null || v == null) continue;
     
    -                    for (edge other : active) {
    +                    for (Edge other : active) {
                             String ou = getEndpoint1(other);
                             String ov = getEndpoint2(other);
                             if (ou == null || ov == null) continue;
    @@ -196,7 +196,7 @@ private void compute() {
                 }
     
                 // All remaining edges have support >= k-2, increase k
    -            for (edge e : active) {
    +            for (Edge e : active) {
                     trussNumbers.put(e, k + 1); // tentative — will be overwritten if removed later
                 }
                 k++;
    @@ -217,7 +217,7 @@ private void compute() {
          * @param e the edge
          * @return the truss number, or 0 if edge not in graph
          */
    -    public int getTrussNumber(edge e) {
    +    public int getTrussNumber(Edge e) {
             ensureComputed();
             return trussNumbers.getOrDefault(e, 0);
         }
    @@ -239,9 +239,9 @@ public int getMaxTrussNumber() {
          * @param k the truss parameter (k ≥ 2)
          * @return a new graph containing only edges in the k-truss
          */
    -    public Graph getKTruss(int k) {
    +    public Graph getKTruss(int k) {
             ensureComputed();
    -        Graph subgraph = new UndirectedSparseGraph<>();
    +        Graph subgraph = new UndirectedSparseGraph<>();
     
             for (Map.Entry entry : trussNumbers.entrySet()) {
                 if (entry.getValue() >= k) {
    @@ -280,7 +280,7 @@ public Map getTrussDistribution() {
          * @param e the edge
          * @return number of triangles containing this edge
          */
    -    public int getTriangleSupport(edge e) {
    +    public int getTriangleSupport(Edge e) {
             ensureComputed();
             return triangleSupport.getOrDefault(e, 0);
         }
    @@ -291,9 +291,9 @@ public int getTriangleSupport(edge e) {
          *
          * @return map from k to the set of edges in the k-truss but not in the (k+1)-truss
          */
    -    public Map> getTrussHierarchy() {
    +    public Map> getTrussHierarchy() {
             ensureComputed();
    -        Map> hierarchy = new TreeMap<>();
    +        Map> hierarchy = new TreeMap<>();
             for (Map.Entry entry : trussNumbers.entrySet()) {
                 hierarchy.computeIfAbsent(entry.getValue(), k -> new ArrayList<>())
                         .add(entry.getKey());
    @@ -323,7 +323,7 @@ public List compareTrussVsCore() {
             Map vertexTruss = new LinkedHashMap<>();
             for (String v : graph.getVertices()) {
                 int maxT = 0;
    -            for (edge e : graph.getIncidentEdges(v)) {
    +            for (Edge e : graph.getIncidentEdges(v)) {
                     maxT = Math.max(maxT, trussNumbers.getOrDefault(e, 0));
                 }
                 vertexTruss.put(v, maxT);
    @@ -397,9 +397,9 @@ public String getSummary() {
     
         // --- Helper methods ---
     
    -    private Map> buildAdjacency(Set edges) {
    +    private Map> buildAdjacency(Set edges) {
             Map> adj = new LinkedHashMap<>();
    -        for (edge e : edges) {
    +        for (Edge e : edges) {
                 String u = getEndpoint1(e);
                 String v = getEndpoint2(e);
                 if (u != null && v != null) {
    @@ -410,14 +410,14 @@ private Map> buildAdjacency(Set edges) {
             return adj;
         }
     
    -    private String getEndpoint1(edge e) {
    +    private String getEndpoint1(Edge e) {
             Collection endpoints = graph.getEndpoints(e);
             if (endpoints == null || endpoints.isEmpty()) return null;
             Iterator it = endpoints.iterator();
             return it.next();
         }
     
    -    private String getEndpoint2(edge e) {
    +    private String getEndpoint2(Edge e) {
             Collection endpoints = graph.getEndpoints(e);
             if (endpoints == null || endpoints.size() < 2) return null;
             Iterator it = endpoints.iterator();
    @@ -425,8 +425,8 @@ private String getEndpoint2(edge e) {
             return it.next();
         }
     
    -    private edge findEdge(Set edges, String u, String v) {
    -        for (edge e : edges) {
    +    private edge findEdge(Set edges, String u, String v) {
    +        for (Edge e : edges) {
                 String eu = getEndpoint1(e);
                 String ev = getEndpoint2(e);
                 if ((u.equals(eu) && v.equals(ev)) || (u.equals(ev) && v.equals(eu))) {
    @@ -436,8 +436,8 @@ private edge findEdge(Set edges, String u, String v) {
             return null;
         }
     
    -    private boolean hasActiveEdge(Set active, String u, String v) {
    -        for (edge e : active) {
    +    private boolean hasActiveEdge(Set active, String u, String v) {
    +        for (Edge e : active) {
                 String eu = getEndpoint1(e);
                 String ev = getEndpoint2(e);
                 if ((u.equals(eu) && v.equals(ev)) || (u.equals(ev) && v.equals(eu))) {
    diff --git a/Gvisual/src/gvisual/LaplacianBuilder.java b/Gvisual/src/gvisual/LaplacianBuilder.java
    index 5c3fe82..7df045e 100644
    --- a/Gvisual/src/gvisual/LaplacianBuilder.java
    +++ b/Gvisual/src/gvisual/LaplacianBuilder.java
    @@ -41,7 +41,7 @@ private LaplacianBuilder() {
          * @param vertexList ordered list of vertices (defines row/column mapping)
          * @return n×n adjacency matrix
          */
    -    public static double[][] buildAdjacencyMatrix(Graph graph,
    +    public static double[][] buildAdjacencyMatrix(Graph graph,
                                                        List vertexList) {
             int n = vertexList.size();
             double[][] A = new double[n][n];
    @@ -50,7 +50,7 @@ public static double[][] buildAdjacencyMatrix(Graph graph,
                 indexMap.put(vertexList.get(i), i);
             }
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection endpoints = graph.getEndpoints(e);
                 Iterator it = endpoints.iterator();
                 String u = it.next();
    @@ -114,7 +114,7 @@ public static double[][] buildLaplacian(double[][] A, int n) {
          * @param vertexList ordered list of vertices
          * @return L = D − A
          */
    -    public static double[][] buildLaplacian(Graph graph,
    +    public static double[][] buildLaplacian(Graph graph,
                                                  List vertexList) {
             double[][] A = buildAdjacencyMatrix(graph, vertexList);
             return buildLaplacian(A, vertexList.size());
    @@ -128,7 +128,7 @@ public static double[][] buildLaplacian(Graph graph,
          * @param vertices ordered subset of vertices
          * @return n×n Laplacian for the induced subgraph
          */
    -    public static double[][] buildSubgraphLaplacian(Graph graph,
    +    public static double[][] buildSubgraphLaplacian(Graph graph,
                                                           List vertices) {
             int n = vertices.size();
             Map index = new HashMap<>();
    @@ -191,7 +191,7 @@ public static double[][] buildNormalizedLaplacian(double[][] A, int n) {
          * @param vertexList ordered list of vertices
          * @return normalized Laplacian matrix
          */
    -    public static double[][] buildNormalizedLaplacian(Graph graph,
    +    public static double[][] buildNormalizedLaplacian(Graph graph,
                                                            List vertexList) {
             double[][] A = buildAdjacencyMatrix(graph, vertexList);
             return buildNormalizedLaplacian(A, vertexList.size());
    @@ -233,7 +233,7 @@ public static double[][] buildRandomWalkLaplacian(double[][] A, int n) {
          * @param vertexList ordered list of vertices
          * @return random walk Laplacian matrix
          */
    -    public static double[][] buildRandomWalkLaplacian(Graph graph,
    +    public static double[][] buildRandomWalkLaplacian(Graph graph,
                                                             List vertexList) {
             double[][] A = buildAdjacencyMatrix(graph, vertexList);
             return buildRandomWalkLaplacian(A, vertexList.size());
    diff --git a/Gvisual/src/gvisual/LineGraphAnalyzer.java b/Gvisual/src/gvisual/LineGraphAnalyzer.java
    index 0c9aac8..4394c2e 100644
    --- a/Gvisual/src/gvisual/LineGraphAnalyzer.java
    +++ b/Gvisual/src/gvisual/LineGraphAnalyzer.java
    @@ -31,13 +31,13 @@
      */
     public class LineGraphAnalyzer {
     
    -    private final Graph graph;
    -    private Graph lineGraph;
    -    private Map vertexToEdge;
    +    private final Graph graph;
    +    private Graph lineGraph;
    +    private Map vertexToEdge;
         private Map edgeToVertex;
         private boolean computed;
     
    -    public LineGraphAnalyzer(Graph graph) {
    +    public LineGraphAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -53,11 +53,11 @@ private void ensureComputed() {
         }
     
         private void buildLineGraph() {
    -        lineGraph = new UndirectedSparseGraph();
    -        vertexToEdge = new LinkedHashMap();
    +        lineGraph = new UndirectedSparseGraph();
    +        vertexToEdge = new LinkedHashMap();
             edgeToVertex = new HashMap();
     
    -        List edges = new ArrayList(graph.getEdges());
    +        List edges = new ArrayList(graph.getEdges());
             for (int i = 0; i < edges.size(); i++) {
                 edge e = edges.get(i);
                 String label = edgeLabel(e);
    @@ -73,7 +73,7 @@ private void buildLineGraph() {
                     if (sharesEndpoint(e1, e2)) {
                         String v1 = edgeToVertex.get(edgeKey(e1));
                         String v2 = edgeToVertex.get(edgeKey(e2));
    -                    edge lgEdge = new edge("lg", v1, v2);
    +                    edge lgEdge = new Edge("lg", v1, v2);
                         lgEdge.setLabel(v1 + "-" + v2);
                         lineGraph.addEdge(lgEdge, v1, v2);
                     }
    @@ -81,7 +81,7 @@ private void buildLineGraph() {
             }
         }
     
    -    private String edgeLabel(edge e) {
    +    private String edgeLabel(Edge e) {
             String v1 = null, v2 = null;
             Collection endpoints = graph.getEndpoints(e);
             if (endpoints != null && endpoints.size() == 2) {
    @@ -98,18 +98,18 @@ private String edgeLabel(edge e) {
             return "e" + System.identityHashCode(e);
         }
     
    -    private String edgeKey(edge e) {
    +    private String edgeKey(Edge e) {
             return edgeLabel(e);
         }
     
    -    private boolean sharesEndpoint(edge e1, edge e2) {
    +    private boolean sharesEndpoint(Edge e1, edge e2) {
             String[] ep1 = getEndpoints(e1);
             String[] ep2 = getEndpoints(e2);
             return ep1[0].equals(ep2[0]) || ep1[0].equals(ep2[1])
                 || ep1[1].equals(ep2[0]) || ep1[1].equals(ep2[1]);
         }
     
    -    private String[] getEndpoints(edge e) {
    +    private String[] getEndpoints(Edge e) {
             Collection endpoints = graph.getEndpoints(e);
             if (endpoints != null && endpoints.size() == 2) {
                 Iterator it = endpoints.iterator();
    @@ -122,12 +122,12 @@ private String[] getEndpoints(edge e) {
     
         // ── Accessors ───────────────────────────────────────────────────
     
    -    public Graph getLineGraph() {
    +    public Graph getLineGraph() {
             ensureComputed();
             return lineGraph;
         }
     
    -    public Map getVertexToEdgeMapping() {
    +    public Map getVertexToEdgeMapping() {
             ensureComputed();
             return Collections.unmodifiableMap(vertexToEdge);
         }
    @@ -286,7 +286,7 @@ public IteratedResult iteratedLineGraphs(int iterations) {
             List seq = new ArrayList();
             seq.add(new int[]{graph.getVertexCount(), graph.getEdgeCount()});
     
    -        Graph current = graph;
    +        Graph current = graph;
             String convergence = "growing";
     
             for (int i = 0; i < iterations; i++) {
    @@ -502,7 +502,7 @@ public Map> vertexEdgeCliques() {
     
             for (String v : graph.getVertices()) {
                 Set clique = new TreeSet();
    -            for (edge e : graph.getIncidentEdges(v)) {
    +            for (Edge e : graph.getIncidentEdges(v)) {
                     String label = edgeToVertex.get(edgeKey(e));
                     if (label != null) clique.add(label);
                 }
    diff --git a/Gvisual/src/gvisual/LinkPredictionAnalyzer.java b/Gvisual/src/gvisual/LinkPredictionAnalyzer.java
    index 950c003..ab08ff9 100644
    --- a/Gvisual/src/gvisual/LinkPredictionAnalyzer.java
    +++ b/Gvisual/src/gvisual/LinkPredictionAnalyzer.java
    @@ -28,7 +28,7 @@
      */
     public class LinkPredictionAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /**
          * Create a new link prediction analyzer.
    @@ -36,7 +36,7 @@ public class LinkPredictionAnalyzer {
          * @param graph the JUNG graph to analyze (must not be null)
          * @throws IllegalArgumentException if graph is null
          */
    -    public LinkPredictionAnalyzer(Graph graph) {
    +    public LinkPredictionAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    diff --git a/Gvisual/src/gvisual/LouvainCommunityDetector.java b/Gvisual/src/gvisual/LouvainCommunityDetector.java
    index 5beec01..717cedc 100644
    --- a/Gvisual/src/gvisual/LouvainCommunityDetector.java
    +++ b/Gvisual/src/gvisual/LouvainCommunityDetector.java
    @@ -21,14 +21,14 @@
      */
     public class LouvainCommunityDetector {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private final double resolution;
     
    -    public LouvainCommunityDetector(Graph graph) {
    +    public LouvainCommunityDetector(Graph graph) {
             this(graph, 1.0);
         }
     
    -    public LouvainCommunityDetector(Graph graph, double resolution) {
    +    public LouvainCommunityDetector(Graph graph, double resolution) {
             if (graph == null) throw new IllegalArgumentException("Graph must not be null");
             if (resolution <= 0) throw new IllegalArgumentException("Resolution must be positive");
             this.graph = graph;
    @@ -324,8 +324,8 @@ public LouvainResult detect() {
                 cmap.get(cid).members.add(e.getKey());
             }
     
    -        Set counted = new HashSet();
    -        for (edge e : graph.getEdges()) {
    +        Set counted = new HashSet();
    +        for (Edge e : graph.getEdges()) {
                 if (counted.contains(e)) continue;
                 counted.add(e);
                 Integer c1 = finalAssign.get(e.getVertex1());
    @@ -360,7 +360,7 @@ public LouvainResult detect() {
         private List> buildAdjacency(Map nodeIndex, int n) {
             List> adj = new ArrayList>();
             for (int i = 0; i < n; i++) adj.add(new HashMap());
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Integer i = nodeIndex.get(e.getVertex1());
                 Integer j = nodeIndex.get(e.getVertex2());
                 if (i == null || j == null) continue;
    diff --git a/Gvisual/src/gvisual/MSTPanelController.java b/Gvisual/src/gvisual/MSTPanelController.java
    index 4afb061..eda3bd7 100644
    --- a/Gvisual/src/gvisual/MSTPanelController.java
    +++ b/Gvisual/src/gvisual/MSTPanelController.java
    @@ -20,7 +20,7 @@ public class MSTPanelController {
     
         /** Callback for obtaining the graph and requesting repaints. */
         public interface GraphHost {
    -        Graph getGraph();
    +        Graph getGraph();
             void onOverlayChanged();
         }
     
    @@ -28,7 +28,7 @@ public interface GraphHost {
         private final JPanel panel;
     
         private boolean overlayActive;
    -    private final Set mstEdges = new HashSet<>();
    +    private final Set mstEdges = new HashSet<>();
     
         private final JLabel summaryLabel;
         private final JLabel statsLabel;
    @@ -85,7 +85,7 @@ public MSTPanelController(GraphHost host) {
     
         public JPanel getPanel() { return panel; }
         public boolean isOverlayActive() { return overlayActive; }
    -    public Set getMstEdges() { return mstEdges; }
    +    public Set getMstEdges() { return mstEdges; }
     
         private String getDominantLabel(String typeCode) {
             EdgeType type = EdgeType.fromCode(typeCode);
    @@ -93,7 +93,7 @@ private String getDominantLabel(String typeCode) {
         }
     
         private void runComputation() {
    -        Graph g = host.getGraph();
    +        Graph g = host.getGraph();
             if (g == null || g.getVertexCount() == 0) {
                 summaryLabel.setText("No graph loaded.");
                 return;
    diff --git a/Gvisual/src/gvisual/Main.java b/Gvisual/src/gvisual/Main.java
    index 9d0028e..bd245b1 100644
    --- a/Gvisual/src/gvisual/Main.java
    +++ b/Gvisual/src/gvisual/Main.java
    @@ -1,4 +1,4 @@
    -package gvisual;
    +package gvisual;
     
     import app.Network;
     import edu.uci.ics.jung.algorithms.layout.Layout;
    @@ -97,9 +97,9 @@ public class Main extends JFrame {
         private String month;
         private String date;
         private String timeStamp;
    -    private Graph g;
    -    private VisualizationViewer vv;
    -    private Layout graphLayout;
    +    private Graph g;
    +    private VisualizationViewer vv;
    +    private Layout graphLayout;
         private final GraphRenderers renderers = new GraphRenderers();
     
         /**
    @@ -123,11 +123,11 @@ private void syncRenderers() {
             renderers.setEgoState(egoController.isOverlayActive(), egoController.getCenter(), egoController.getNeighbors(), egoController.getEdges());
             renderers.setOldVertices(OldVertices);
         }
    -    private List friendEdges = new ArrayList<>();
    -    private List fsEdges = new ArrayList<>();
    -    private List classmateEdges = new ArrayList<>();
    -    private List strangerEdges = new ArrayList<>();
    -    private List studyGEdges = new ArrayList<>();
    +    private List friendEdges = new ArrayList<>();
    +    private List fsEdges = new ArrayList<>();
    +    private List classmateEdges = new ArrayList<>();
    +    private List strangerEdges = new ArrayList<>();
    +    private List studyGEdges = new ArrayList<>();
         private String fileName;
         private Box parameterSpace;
         private JPanel notesPanel;
    @@ -230,7 +230,7 @@ public Main() throws FileNotFoundException, Exception {
          * Returns the edge list for the given edge type.
          * Used to replace the cascading if/else chain in addGraph().
          */
    -    private List getEdgeList(EdgeType type) {
    +    private List getEdgeList(EdgeType type) {
             switch (type) {
                 case FRIEND:      return friendEdges;
                 case CLASSMATE:   return classmateEdges;
    @@ -262,7 +262,7 @@ private boolean isEdgeTypeVisible(String typeCode) {
          * Create the layout for the graph
          */
         public void createLayout() {
    -        graphLayout = new StaticLayout(g);
    +        graphLayout = new StaticLayout(g);
             List> clusters = new ArrayList<>();
     
             for (int i = 0; i < 9; i++) {
    @@ -276,7 +276,7 @@ public void createLayout() {
                 boolean isS = false;
                 boolean isSg = false;
                 int areaId;
    -            for (edge y : g.getOutEdges(x)) {
    +            for (Edge y : g.getOutEdges(x)) {
                     EdgeType type = EdgeType.fromCode(y.getType());
                     if (type != null) {
                         switch (type) {
    @@ -441,7 +441,7 @@ private static class CategoryRow {
          * @return a fully-initialised {@code CategoryRow}
          */
         private CategoryRow createCategoryRow(final EdgeType type,
    -                                          final List edgeList,
    +                                          final List edgeList,
                                               String labelText,
                                               int durMax) {
             JButton settingsBtn = new JButton(new ImageIcon("./images/settings.png"));
    @@ -451,9 +451,9 @@ private CategoryRow createCategoryRow(final EdgeType type,
             cb.setSelected(true);
             cb.addActionListener(e -> {
                 if (cb.isSelected()) {
    -                for (edge x : edgeList) { g.addEdge(x, x.getVertex1(), x.getVertex2()); }
    +                for (Edge x : edgeList) { g.addEdge(x, x.getVertex1(), x.getVertex2()); }
                 } else {
    -                for (edge x : edgeList) { g.removeEdge(x); }
    +                for (Edge x : edgeList) { g.removeEdge(x); }
                 }
                 imagePanel.setVisible(false);
                 imagePanel.setVisible(true);
    @@ -581,7 +581,7 @@ public void addGraph() throws ParserConfigurationException, IOException, SAXExce
     
             // Populate classified edge lists from parse result
             for (EdgeType type : EdgeType.values()) {
    -            List list = getEdgeList(type);
    +            List list = getEdgeList(type);
                 if (list != null) {
                     list.clear();
                     list.addAll(parseResult.getEdges(type));
    @@ -589,7 +589,7 @@ public void addGraph() throws ParserConfigurationException, IOException, SAXExce
             }
     
             createLayout();
    -        vv = new VisualizationViewer(graphLayout);
    +        vv = new VisualizationViewer(graphLayout);
             vv.setSize(new Dimension(100, 0));
     
             DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    @@ -598,7 +598,7 @@ public void addGraph() throws ParserConfigurationException, IOException, SAXExce
             vv.setGraphMouse(gm);
     
     
    -        Transformer edgeLabel = (edge i) -> {
    +        Transformer edgeLabel = (Edge i) -> {
                     return i.getLabel();
                 };
     
    @@ -707,9 +707,9 @@ public final void initializeLegendSpace(){
          */
         public final void initializePathController() {
             pathController = new PathPanelController(new PathPanelController.GraphHost() {
    -            @Override public Graph getGraph() { return g; }
    -            @Override public edu.uci.ics.jung.algorithms.layout.Layout getLayout() { return graphLayout; }
    -            @Override public VisualizationViewer getViewer() { return vv; }
    +            @Override public Graph getGraph() { return g; }
    +            @Override public edu.uci.ics.jung.algorithms.layout.Layout getLayout() { return graphLayout; }
    +            @Override public VisualizationViewer getViewer() { return vv; }
                 @Override public void refreshGraph() { Main.this.refreshGraph(); }
             });
         }
    @@ -730,7 +730,7 @@ private void refreshGraph() {
          */
         public final void initializeCommunityController() {
             communityController = new CommunityPanelController(new CommunityPanelController.GraphHost() {
    -            @Override public Graph getGraph() { return g; }
    +            @Override public Graph getGraph() { return g; }
                 @Override public void onOverlayChanged() { syncRenderers(); refreshGraph(); }
             });
         }
    @@ -748,7 +748,7 @@ private String getDominantLabel(String typeCode) {
          */
         public final void initializeMSTController() {
             mstController = new MSTPanelController(new MSTPanelController.GraphHost() {
    -            @Override public Graph getGraph() { return g; }
    +            @Override public Graph getGraph() { return g; }
                 @Override public void onOverlayChanged() { syncRenderers(); refreshGraph(); }
             });
         }
    @@ -1128,10 +1128,10 @@ public final void initializeCategoryPanel() {
          */
         public final void initializeToolBar() {
             ToolbarBuilder.GraphContext ctx = new ToolbarBuilder.GraphContext() {
    -            @Override public Graph getGraph() { return g; }
    -            @Override public VisualizationViewer getVisualizationViewer() { return vv; }
    +            @Override public Graph getGraph() { return g; }
    +            @Override public VisualizationViewer getVisualizationViewer() { return vv; }
                 @Override public String getTimestamp() { return timeStamp; }
    -            @Override public List collectAllEdges() { return Main.this.collectAllEdges(); }
    +            @Override public List collectAllEdges() { return Main.this.collectAllEdges(); }
             };
             toolPanel = ToolbarBuilder.build(Main.this, ctx, legendPanel);
             contentPanel.add(toolPanel, BorderLayout.WEST);
    @@ -1141,10 +1141,10 @@ public final void initializeToolBar() {
          * Collects all edges from every category into a single list.
          * Replaces the 5-line addAll() pattern duplicated across export handlers.
          */
    -    private List collectAllEdges() {
    -        List allEdges = new ArrayList<>();
    +    private List collectAllEdges() {
    +        List allEdges = new ArrayList<>();
             for (EdgeType type : EdgeType.values()) {
    -            List list = getEdgeList(type);
    +            List list = getEdgeList(type);
                 if (list != null) {
                     allEdges.addAll(list);
                 }
    diff --git a/Gvisual/src/gvisual/MaxCutAnalyzer.java b/Gvisual/src/gvisual/MaxCutAnalyzer.java
    index b1151d4..59aa896 100644
    --- a/Gvisual/src/gvisual/MaxCutAnalyzer.java
    +++ b/Gvisual/src/gvisual/MaxCutAnalyzer.java
    @@ -38,11 +38,11 @@
      */
     public class MaxCutAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private static final int EXACT_LIMIT = 20;
         private static final int RANDOM_RESTARTS = 25;
     
    -    public MaxCutAnalyzer(Graph graph) {
    +    public MaxCutAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -54,20 +54,20 @@ public static class CutResult {
             private final Set setT;
             private final double cutValue;
             private final int cutEdgeCount;
    -        private final List cutEdges;
    +        private final List cutEdges;
             private final String algorithm;
             private final int totalEdges;
             private final double cutRatio;
     
             public CutResult(Set setS, Set setT,
                               double cutValue, int cutEdgeCount,
    -                          List cutEdges, String algorithm,
    +                          List cutEdges, String algorithm,
                               int totalEdges) {
                 this.setS = Collections.unmodifiableSet(new LinkedHashSet(setS));
                 this.setT = Collections.unmodifiableSet(new LinkedHashSet(setT));
                 this.cutValue = cutValue;
                 this.cutEdgeCount = cutEdgeCount;
    -            this.cutEdges = Collections.unmodifiableList(new ArrayList(cutEdges));
    +            this.cutEdges = Collections.unmodifiableList(new ArrayList(cutEdges));
                 this.algorithm = algorithm;
                 this.totalEdges = totalEdges;
                 this.cutRatio = totalEdges > 0 ? (double) cutEdgeCount / totalEdges : 0.0;
    @@ -77,7 +77,7 @@ public CutResult(Set setS, Set setT,
             public Set getSetT() { return setT; }
             public double getCutValue() { return cutValue; }
             public int getCutEdgeCount() { return cutEdgeCount; }
    -        public List getCutEdges() { return cutEdges; }
    +        public List getCutEdges() { return cutEdges; }
             public String getAlgorithm() { return algorithm; }
             public int getTotalEdges() { return totalEdges; }
             public double getCutRatio() { return cutRatio; }
    @@ -186,7 +186,7 @@ public double computeUpperBound() {
             int n = graph.getVertexCount();
             if (n <= 1 || edgeCount == 0) return 0.0;
             double totalWeight = 0;
    -        for (edge e : graph.getEdges()) totalWeight += Math.max(e.getWeight(), 1.0f);
    +        for (Edge e : graph.getEdges()) totalWeight += Math.max(e.getWeight(), 1.0f);
             // Edwards bound is a guaranteed lower bound, not an upper bound.
             // The trivial upper bound is total edge weight (every edge cut).
             return totalWeight;
    @@ -201,7 +201,7 @@ public double computeLowerBound() {
         public Map computeVertexContributions(CutResult result) {
             Map contributions = new LinkedHashMap();
             for (String v : graph.getVertices()) contributions.put(v, 0);
    -        for (edge e : result.getCutEdges()) {
    +        for (Edge e : result.getCutEdges()) {
                 String v1 = e.getVertex1(), v2 = e.getVertex2();
                 if (contributions.containsKey(v1)) contributions.put(v1, contributions.get(v1) + 1);
                 if (contributions.containsKey(v2)) contributions.put(v2, contributions.get(v2) + 1);
    @@ -337,9 +337,9 @@ private int countNeighborsIn(String v, Set set) {
     
         private double weightedNeighborsIn(String v, Set set) {
             double total = 0;
    -        Collection incidentEdges = graph.getIncidentEdges(v);
    +        Collection incidentEdges = graph.getIncidentEdges(v);
             if (incidentEdges != null) {
    -            for (edge e : incidentEdges) {
    +            for (Edge e : incidentEdges) {
                     String other = GraphUtils.getOtherEnd(e, v);
                     if (other != null && set.contains(other)) total += Math.max(e.getWeight(), 1.0f);
                 }
    @@ -370,7 +370,7 @@ private CutResult refineByFlipping(Set setS, Set setT, String al
     
         private double evaluateCutByMask(List vertexList, long mask) {
             double cutValue = 0;
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 int i1 = vertexList.indexOf(e.getVertex1()), i2 = vertexList.indexOf(e.getVertex2());
                 if (i1 < 0 || i2 < 0) continue;
                 if (((mask & (1L << i1)) != 0) != ((mask & (1L << i2)) != 0))
    @@ -381,8 +381,8 @@ private double evaluateCutByMask(List vertexList, long mask) {
     
         private CutResult buildResult(Set setS, Set setT, String algorithm) {
             double cutValue = 0; int cutEdgeCount = 0;
    -        List cutEdges = new ArrayList();
    -        for (edge e : graph.getEdges()) {
    +        List cutEdges = new ArrayList();
    +        for (Edge e : graph.getEdges()) {
                 if (setS.contains(e.getVertex1()) != setS.contains(e.getVertex2())) {
                     cutEdges.add(e); cutEdgeCount++;
                     cutValue += Math.max(e.getWeight(), 1.0f);
    @@ -393,6 +393,6 @@ private CutResult buildResult(Set setS, Set setT, String algorit
     
         private CutResult emptyCut(String algorithm) {
             return new CutResult(new LinkedHashSet(), new LinkedHashSet(),
    -            0.0, 0, new ArrayList(), algorithm, 0);
    +            0.0, 0, new ArrayList(), algorithm, 0);
         }
     }
    diff --git a/Gvisual/src/gvisual/MetricDimensionAnalyzer.java b/Gvisual/src/gvisual/MetricDimensionAnalyzer.java
    index 258553a..700c1d3 100644
    --- a/Gvisual/src/gvisual/MetricDimensionAnalyzer.java
    +++ b/Gvisual/src/gvisual/MetricDimensionAnalyzer.java
    @@ -57,7 +57,7 @@
      */
     public class MetricDimensionAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private List vertices;
         private int n;
         private int[][] dist;
    @@ -73,7 +73,7 @@ public class MetricDimensionAnalyzer {
         /** Maximum vertex count for exact computation. */
         private static final int EXACT_LIMIT = 30;
     
    -    public MetricDimensionAnalyzer(Graph graph) {
    +    public MetricDimensionAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    diff --git a/Gvisual/src/gvisual/MinimumSpanningTree.java b/Gvisual/src/gvisual/MinimumSpanningTree.java
    index 5441c97..d285641 100644
    --- a/Gvisual/src/gvisual/MinimumSpanningTree.java
    +++ b/Gvisual/src/gvisual/MinimumSpanningTree.java
    @@ -23,7 +23,7 @@
      */
     public class MinimumSpanningTree {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /**
          * Create a new MST analyzer for the given graph.
    @@ -31,7 +31,7 @@ public class MinimumSpanningTree {
          * @param graph the JUNG graph to analyze (must not be null)
          * @throws IllegalArgumentException if graph is null
          */
    -    public MinimumSpanningTree(Graph graph) {
    +    public MinimumSpanningTree(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -55,25 +55,25 @@ public MSTResult compute() {
             }
     
             // Collect all edges and sort by weight (Kruskal's)
    -        List sortedEdges = new ArrayList();
    -        Set seen = new HashSet();
    -        for (edge e : graph.getEdges()) {
    +        List sortedEdges = new ArrayList();
    +        Set seen = new HashSet();
    +        for (Edge e : graph.getEdges()) {
                 if (!seen.contains(e)) {
                     sortedEdges.add(e);
                     seen.add(e);
                 }
             }
    -        Collections.sort(sortedEdges, (edge a, edge b) -> {
    +        Collections.sort(sortedEdges, (Edge a, edge b) -> {
                     return Float.compare(a.getWeight(), b.getWeight());
                 });
     
             // Union-Find
             UnionFind uf = new UnionFind(vertices);
     
    -        List mstEdges = new ArrayList();
    +        List mstEdges = new ArrayList();
             float totalWeight = 0.0f;
     
    -        for (edge e : sortedEdges) {
    +        for (Edge e : sortedEdges) {
                 String u = e.getVertex1();
                 String v = e.getVertex2();
                 if (!uf.find(u).equals(uf.find(v))) {
    @@ -96,12 +96,12 @@ public MSTResult compute() {
             }
     
             // Map edges to their component
    -        Map> rootToEdges = new LinkedHashMap>();
    -        for (edge e : mstEdges) {
    +        Map> rootToEdges = new LinkedHashMap>();
    +        for (Edge e : mstEdges) {
                 String root = uf.find(e.getVertex1());
    -            List compEdges = rootToEdges.get(root);
    +            List compEdges = rootToEdges.get(root);
                 if (compEdges == null) {
    -                compEdges = new ArrayList();
    +                compEdges = new ArrayList();
                     rootToEdges.put(root, compEdges);
                 }
                 compEdges.add(e);
    @@ -119,11 +119,11 @@ public MSTResult compute() {
             for (Map.Entry> entry : sortedComps) {
                 String root = entry.getKey();
                 List members = entry.getValue();
    -            List compEdges = rootToEdges.get(root);
    +            List compEdges = rootToEdges.get(root);
                 if (compEdges == null) compEdges = Collections.emptyList();
     
                 float compWeight = 0.0f;
    -            for (edge e : compEdges) {
    +            for (Edge e : compEdges) {
                     compWeight += e.getWeight();
                 }
     
    @@ -204,14 +204,14 @@ void union(String a, String b) {
          * Complete MST computation result.
          */
         public static class MSTResult {
    -        private final List edges;
    +        private final List edges;
             private final List components;
             private final int componentCount;
             private final float totalWeight;
             private final int edgeCount;
             private final int vertexCount;
     
    -        MSTResult(List edges, List components,
    +        MSTResult(List edges, List components,
                       int componentCount, float totalWeight, int edgeCount, int vertexCount) {
                 this.edges = Collections.unmodifiableList(edges);
                 this.components = Collections.unmodifiableList(components);
    @@ -222,7 +222,7 @@ public static class MSTResult {
             }
     
             /** All MST edges. */
    -        public List getEdges() { return edges; }
    +        public List getEdges() { return edges; }
     
             /** Per-component breakdown. */
             public List getComponents() { return components; }
    @@ -254,7 +254,7 @@ public boolean isConnected() {
              */
             public Map getEdgeTypeDistribution() {
                 Map dist = new LinkedHashMap();
    -            for (edge e : edges) {
    +            for (Edge e : edges) {
                     String type = e.getType();
                     if (type == null) type = "unknown";
                     Integer count = dist.get(type);
    @@ -284,7 +284,7 @@ public String getSummary() {
              */
             public edge getHeaviestEdge() {
                 edge heaviest = null;
    -            for (edge e : edges) {
    +            for (Edge e : edges) {
                     if (heaviest == null || e.getWeight() > heaviest.getWeight()) {
                         heaviest = e;
                     }
    @@ -299,7 +299,7 @@ public edge getHeaviestEdge() {
              */
             public edge getLightestEdge() {
                 edge lightest = null;
    -            for (edge e : edges) {
    +            for (Edge e : edges) {
                     if (lightest == null || e.getWeight() < lightest.getWeight()) {
                         lightest = e;
                     }
    @@ -324,10 +324,10 @@ public float getAverageWeight() {
         public static class MSTComponent {
             private final int id;
             private final List vertices;
    -        private final List edges;
    +        private final List edges;
             private final float totalWeight;
     
    -        MSTComponent(int id, List vertices, List edges, float totalWeight) {
    +        MSTComponent(int id, List vertices, List edges, float totalWeight) {
                 this.id = id;
                 this.vertices = Collections.unmodifiableList(vertices);
                 this.edges = Collections.unmodifiableList(edges);
    @@ -341,7 +341,7 @@ public static class MSTComponent {
             public List getVertices() { return vertices; }
     
             /** MST edges in this component. */
    -        public List getEdges() { return edges; }
    +        public List getEdges() { return edges; }
     
             /** Total weight of MST edges in this component. */
             public float getTotalWeight() { return totalWeight; }
    @@ -356,7 +356,7 @@ public static class MSTComponent {
              */
             public String getDominantType() {
                 Map counts = new HashMap();
    -            for (edge e : edges) {
    +            for (Edge e : edges) {
                     String type = e.getType();
                     if (type == null) type = "unknown";
                     Integer c = counts.get(type);
    diff --git a/Gvisual/src/gvisual/MotifAnalyzer.java b/Gvisual/src/gvisual/MotifAnalyzer.java
    index c898108..4e4fe2c 100644
    --- a/Gvisual/src/gvisual/MotifAnalyzer.java
    +++ b/Gvisual/src/gvisual/MotifAnalyzer.java
    @@ -37,7 +37,7 @@
      */
     public class MotifAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private Map> neighborCache;
         private boolean computed;
     
    @@ -61,7 +61,7 @@ public class MotifAnalyzer {
          * @param graph the JUNG graph to analyze
          * @throws IllegalArgumentException if graph is null
          */
    -    public MotifAnalyzer(Graph graph) {
    +    public MotifAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    diff --git a/Gvisual/src/gvisual/NetworkFlowAnalyzer.java b/Gvisual/src/gvisual/NetworkFlowAnalyzer.java
    index 87a636b..722936c 100644
    --- a/Gvisual/src/gvisual/NetworkFlowAnalyzer.java
    +++ b/Gvisual/src/gvisual/NetworkFlowAnalyzer.java
    @@ -38,7 +38,7 @@
      */
     public class NetworkFlowAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         // Residual capacities: directedKey -> remaining capacity
         private Map, Double> residualCapacity;
    @@ -49,7 +49,7 @@ public class NetworkFlowAnalyzer {
         // Original capacities
         private Map, Double> capacity;
         // Edge lookup: directedKey -> original edge (null for reverse arcs)
    -    private Map, edge> edgeLookup;
    +    private Map, Edge> edgeLookup;
     
         private String source;
         private String sink;
    @@ -63,7 +63,7 @@ public class NetworkFlowAnalyzer {
          *              two directed arcs)
          * @throws IllegalArgumentException if graph is null
          */
    -    public NetworkFlowAnalyzer(Graph graph) {
    +    public NetworkFlowAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -172,7 +172,7 @@ public String getSink() {
         public Map getEdgeFlows() {
             ensureComputed();
             Map result = new LinkedHashMap();
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 List fwd = directedKey(e.getVertex1(), e.getVertex2());
                 List rev = directedKey(e.getVertex2(), e.getVertex1());
     
    @@ -240,14 +240,14 @@ private Set findReachableFromSource() {
          *
          * @return list of edges in the minimum cut
          */
    -    public List getMinCut() {
    +    public List getMinCut() {
             ensureComputed();
     
             Set reachable = findReachableFromSource();
     
             // Min cut edges: original edges with one end in reachable, other not
    -        List cut = new ArrayList();
    -        for (edge e : graph.getEdges()) {
    +        List cut = new ArrayList();
    +        for (Edge e : graph.getEdges()) {
                 String v1 = e.getVertex1();
                 String v2 = e.getVertex2();
                 if ((reachable.contains(v1) && !reachable.contains(v2)) ||
    @@ -275,10 +275,10 @@ public Set getSourceSide() {
          *
          * @return list of bottleneck edges
          */
    -    public List getBottleneckEdges() {
    +    public List getBottleneckEdges() {
             ensureComputed();
    -        List bottlenecks = new ArrayList();
    -        for (edge e : graph.getEdges()) {
    +        List bottlenecks = new ArrayList();
    +        for (Edge e : graph.getEdges()) {
                 String v1 = e.getVertex1();
                 String v2 = e.getVertex2();
                 double cap = getEdgeCapacity(e);
    @@ -302,7 +302,7 @@ public List getBottleneckEdges() {
         public double getTotalCapacity() {
             ensureComputed();
             double total = 0;
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 total += getEdgeCapacity(e);
             }
             return total;
    @@ -317,7 +317,7 @@ public double getTotalCapacity() {
         public double getUtilisation() {
             ensureComputed();
             double sourceCapacity = 0;
    -        for (edge e : graph.getIncidentEdges(source)) {
    +        for (Edge e : graph.getIncidentEdges(source)) {
                 sourceCapacity += getEdgeCapacity(e);
             }
             if (sourceCapacity <= 0) return 0;
    @@ -486,8 +486,8 @@ public FlowResult(String source, String sink, double maxFlow,
         public FlowResult getResult() {
             ensureComputed();
             List paths = decomposeFlowPaths();
    -        List minCut = getMinCut();
    -        List bottlenecks = getBottleneckEdges();
    +        List minCut = getMinCut();
    +        List bottlenecks = getBottleneckEdges();
             return new FlowResult(
                     source, sink, maxFlowValue,
                     getTotalCapacity(), getUtilisation(),
    @@ -508,8 +508,8 @@ public String getSummary() {
     
             // Compute expensive results once
             List paths = decomposeFlowPaths();
    -        List minCut = getMinCut();
    -        List bottlenecks = getBottleneckEdges();
    +        List minCut = getMinCut();
    +        List bottlenecks = getBottleneckEdges();
     
             StringBuilder sb = new StringBuilder();
             sb.append("=== Network Flow Analysis ===\n");
    @@ -533,7 +533,7 @@ public String getSummary() {
             Map edgeFlows = getEdgeFlows();
             if (!edgeFlows.isEmpty()) {
                 sb.append("\n--- Edge flows ---\n");
    -            for (edge e : graph.getEdges()) {
    +            for (Edge e : graph.getEdges()) {
                     String v1 = e.getVertex1();
                     String v2 = e.getVertex2();
                     List fwdKey = directedKey(v1, v2);
    @@ -565,14 +565,14 @@ private void buildResidualGraph() {
             flow = new HashMap, Double>();
             residualAdj = new HashMap>();
             capacity = new HashMap, Double>();
    -        edgeLookup = new HashMap, edge>();
    +        edgeLookup = new HashMap, Edge>();
     
             // Initialise adjacency sets for all vertices
             for (String v : graph.getVertices()) {
                 residualAdj.put(v, new LinkedHashSet());
             }
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String v1 = e.getVertex1();
                 String v2 = e.getVertex2();
                 double cap = getEdgeCapacity(e);
    @@ -634,7 +634,7 @@ private double bfsAugmentingPath(Map parent,
             return 0; // no augmenting path
         }
     
    -    private double getEdgeCapacity(edge e) {
    +    private double getEdgeCapacity(Edge e) {
             float w = e.getWeight();
             return w > 0 ? w : 1.0;
         }
    diff --git a/Gvisual/src/gvisual/NetworkReportGenerator.java b/Gvisual/src/gvisual/NetworkReportGenerator.java
    index 5f6f32e..1f1e228 100644
    --- a/Gvisual/src/gvisual/NetworkReportGenerator.java
    +++ b/Gvisual/src/gvisual/NetworkReportGenerator.java
    @@ -33,20 +33,20 @@
      */
     public class NetworkReportGenerator {
     
    -    private final Graph graph;
    -    private final List friendEdges;
    -    private final List fsEdges;
    -    private final List classmateEdges;
    -    private final List strangerEdges;
    -    private final List studyGEdges;
    +    private final Graph graph;
    +    private final List friendEdges;
    +    private final List fsEdges;
    +    private final List classmateEdges;
    +    private final List strangerEdges;
    +    private final List studyGEdges;
         private String title = "Network Analysis Report";
     
    -    public NetworkReportGenerator(Graph graph,
    -                                   List friendEdges,
    -                                   List fsEdges,
    -                                   List classmateEdges,
    -                                   List strangerEdges,
    -                                   List studyGEdges) {
    +    public NetworkReportGenerator(Graph graph,
    +                                   List friendEdges,
    +                                   List fsEdges,
    +                                   List classmateEdges,
    +                                   List strangerEdges,
    +                                   List studyGEdges) {
             this.graph = graph;
             this.friendEdges = friendEdges != null ? friendEdges : Collections.emptyList();
             this.fsEdges = fsEdges != null ? fsEdges : Collections.emptyList();
    diff --git a/Gvisual/src/gvisual/NetworkRoleClassifier.java b/Gvisual/src/gvisual/NetworkRoleClassifier.java
    index 95836c2..d87f877 100644
    --- a/Gvisual/src/gvisual/NetworkRoleClassifier.java
    +++ b/Gvisual/src/gvisual/NetworkRoleClassifier.java
    @@ -145,7 +145,7 @@ public double getPercentage(StructuralRole role) {
     
         // ── Instance fields ─────────────────────────────────────────
     
    -    private final Graph graph;
    +    private final Graph graph;
         private final Map roles;
         private boolean classified;
     
    @@ -161,7 +161,7 @@ public double getPercentage(StructuralRole role) {
          * @param graph the JUNG graph to analyze (must not be null)
          * @throws IllegalArgumentException if graph is null
          */
    -    public NetworkRoleClassifier(Graph graph) {
    +    public NetworkRoleClassifier(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    diff --git a/Gvisual/src/gvisual/NodeCentralityAnalyzer.java b/Gvisual/src/gvisual/NodeCentralityAnalyzer.java
    index f98b8e8..5887bfe 100644
    --- a/Gvisual/src/gvisual/NodeCentralityAnalyzer.java
    +++ b/Gvisual/src/gvisual/NodeCentralityAnalyzer.java
    @@ -20,7 +20,7 @@
      */
     public class NodeCentralityAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private Map degreeCentrality;
         private Map betweennessCentrality;
         private Map closenessCentrality;
    @@ -32,7 +32,7 @@ public class NodeCentralityAnalyzer {
          * @param graph the JUNG graph to analyze
          * @throws IllegalArgumentException if graph is null
          */
    -    public NodeCentralityAnalyzer(Graph graph) {
    +    public NodeCentralityAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -409,7 +409,7 @@ private void computeBetweennessAndCloseness() {
                 for (int i = 0; i < n; i++) {
                     adjTmp[i] = new ArrayList();
                 }
    -            for (edge e : graph.getEdges()) {
    +            for (Edge e : graph.getEdges()) {
                     Integer ui = idxMap.get(e.getVertex1());
                     Integer vi = idxMap.get(e.getVertex2());
                     if (ui != null && vi != null && !ui.equals(vi)) {
    @@ -525,7 +525,7 @@ private void computeBetweennessAndCloseness() {
             }
         }
     
    -    private String getOtherEnd(edge e, String current) {
    +    private String getOtherEnd(Edge e, String current) {
             return GraphUtils.getOtherEnd(e, current);
         }
     }
    diff --git a/Gvisual/src/gvisual/NodeSimilarityAnalyzer.java b/Gvisual/src/gvisual/NodeSimilarityAnalyzer.java
    index 4261c17..4a553a9 100644
    --- a/Gvisual/src/gvisual/NodeSimilarityAnalyzer.java
    +++ b/Gvisual/src/gvisual/NodeSimilarityAnalyzer.java
    @@ -66,7 +66,7 @@ public String toString() {
             }
         }
     
    -    private final Graph graph;
    +    private final Graph graph;
         // Cached neighbor sets for performance
         private final Map> neighborCache;
     
    @@ -76,7 +76,7 @@ public String toString() {
          * @param graph the JUNG graph to analyze
          * @throws IllegalArgumentException if graph is null
          */
    -    public NodeSimilarityAnalyzer(Graph graph) {
    +    public NodeSimilarityAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    diff --git a/Gvisual/src/gvisual/PageRankAnalyzer.java b/Gvisual/src/gvisual/PageRankAnalyzer.java
    index 17238df..fffbd33 100644
    --- a/Gvisual/src/gvisual/PageRankAnalyzer.java
    +++ b/Gvisual/src/gvisual/PageRankAnalyzer.java
    @@ -40,7 +40,7 @@ public class PageRankAnalyzer {
         /** Default maximum iterations before stopping. */
         public static final int DEFAULT_MAX_ITERATIONS = 100;
     
    -    private final Graph graph;
    +    private final Graph graph;
         private final double dampingFactor;
         private final double tolerance;
         private final int maxIterations;
    @@ -56,7 +56,7 @@ public class PageRankAnalyzer {
          * @param graph the JUNG graph to analyze
          * @throws IllegalArgumentException if graph is null
          */
    -    public PageRankAnalyzer(Graph graph) {
    +    public PageRankAnalyzer(Graph graph) {
             this(graph, DEFAULT_DAMPING, DEFAULT_TOLERANCE, DEFAULT_MAX_ITERATIONS);
         }
     
    @@ -67,7 +67,7 @@ public PageRankAnalyzer(Graph graph) {
          * @param dampingFactor probability of following a link (typically 0.85)
          * @throws IllegalArgumentException if graph is null or damping factor out of range
          */
    -    public PageRankAnalyzer(Graph graph, double dampingFactor) {
    +    public PageRankAnalyzer(Graph graph, double dampingFactor) {
             this(graph, dampingFactor, DEFAULT_TOLERANCE, DEFAULT_MAX_ITERATIONS);
         }
     
    @@ -80,7 +80,7 @@ public PageRankAnalyzer(Graph graph, double dampingFactor) {
          * @param maxIterations maximum number of power iterations
          * @throws IllegalArgumentException if graph is null or parameters out of range
          */
    -    public PageRankAnalyzer(Graph graph, double dampingFactor,
    +    public PageRankAnalyzer(Graph graph, double dampingFactor,
                                 double tolerance, int maxIterations) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
    @@ -217,10 +217,10 @@ public void compute() {
             boolean[] isDangling = new boolean[n];
             for (int i = 0; i < n; i++) {
                 String node = vertexList.get(i);
    -            Collection edges = graph.getIncidentEdges(node);
    +            Collection edges = graph.getIncidentEdges(node);
                 List nodeAdj = new ArrayList();
                 if (edges != null) {
    -                for (edge e : edges) {
    +                for (Edge e : edges) {
                         String other = getOtherEnd(e, node);
                         if (other != null) {
                             Integer idx = vertexIndex.get(other);
    @@ -753,7 +753,7 @@ public String toString() {
     
         // ──────────────── Private helpers ────────────────
     
    -    private String getOtherEnd(edge e, String current) {
    +    private String getOtherEnd(Edge e, String current) {
             return GraphUtils.getOtherEnd(e, current);
         }
     }
    diff --git a/Gvisual/src/gvisual/PathPanelController.java b/Gvisual/src/gvisual/PathPanelController.java
    index 6fc3184..60a6c2f 100644
    --- a/Gvisual/src/gvisual/PathPanelController.java
    +++ b/Gvisual/src/gvisual/PathPanelController.java
    @@ -28,9 +28,9 @@ public class PathPanelController {
     
         /** Callback interface for requesting graph refreshes from the host frame. */
         public interface GraphHost {
    -        Graph getGraph();
    -        Layout getLayout();
    -        VisualizationViewer getViewer();
    +        Graph getGraph();
    +        Layout getLayout();
    +        VisualizationViewer getViewer();
             void refreshGraph();
         }
     
    @@ -42,7 +42,7 @@ public interface GraphHost {
         private String pathSource;
         private String pathTarget;
         private final Set pathVertices = new HashSet<>();
    -    private final Set pathEdges = new HashSet<>();
    +    private final Set pathEdges = new HashSet<>();
     
         // UI components
         private final JLabel sourceLabel;
    @@ -120,7 +120,7 @@ public PathPanelController(GraphHost host) {
     
         public JPanel getPanel() { return panel; }
         public Set getPathVertices() { return pathVertices; }
    -    public Set getPathEdges() { return pathEdges; }
    +    public Set getPathEdges() { return pathEdges; }
         public String getPathSource() { return pathSource; }
         public String getPathTarget() { return pathTarget; }
     
    @@ -168,9 +168,9 @@ private void clearPath() {
         private String findClosestVertex(int screenX, int screenY) {
             String closest = null;
             double minDist = Double.MAX_VALUE;
    -        Graph g = host.getGraph();
    -        Layout layout = host.getLayout();
    -        VisualizationViewer vv = host.getViewer();
    +        Graph g = host.getGraph();
    +        Layout layout = host.getLayout();
    +        VisualizationViewer vv = host.getViewer();
     
             for (String vertex : g.getVertices()) {
                 java.awt.geom.Point2D layoutPoint = layout.transform(vertex);
    @@ -190,7 +190,7 @@ private String findClosestVertex(int screenX, int screenY) {
         private void computeAndHighlightPath() {
             if (pathSource == null || pathTarget == null) return;
     
    -        Graph g = host.getGraph();
    +        Graph g = host.getGraph();
             ShortestPathFinder finder = new ShortestPathFinder(g);
             ShortestPathFinder.PathResult result;
     
    @@ -212,7 +212,7 @@ private void computeAndHighlightPath() {
     
                 String mode = byWeight.isSelected() ? "weight-optimal" : "hop-optimal";
                 StringBuilder edgeTypes = new StringBuilder();
    -            for (edge e : result.getEdges()) {
    +            for (Edge e : result.getEdges()) {
                     if (edgeTypes.length() > 0) edgeTypes.append("\u2192");
                     edgeTypes.append(e.getType());
                 }
    diff --git a/Gvisual/src/gvisual/PlanarGraphAnalyzer.java b/Gvisual/src/gvisual/PlanarGraphAnalyzer.java
    index 1e416d4..d341d15 100644
    --- a/Gvisual/src/gvisual/PlanarGraphAnalyzer.java
    +++ b/Gvisual/src/gvisual/PlanarGraphAnalyzer.java
    @@ -184,7 +184,7 @@ public String toText() {
          * Uses Euler's formula bound (E ≤ 3V - 6) as a quick reject,
          * then attempts to build a planar embedding via ordered DFS.
          */
    -    public static PlanarityResult testPlanarity(Graph graph) {
    +    public static PlanarityResult testPlanarity(Graph graph) {
             if (graph == null) throw new IllegalArgumentException("graph is null");
     
             int V = graph.getVertexCount();
    @@ -221,7 +221,7 @@ public static PlanarityResult testPlanarity(Graph graph) {
          * Enumerates all faces of a planar graph by building a combinatorial
          * embedding and tracing face-walks. Returns null if non-planar.
          */
    -    public static List enumerateFaces(Graph graph) {
    +    public static List enumerateFaces(Graph graph) {
             PlanarityResult pr = testPlanarity(graph);
             if (!pr.isPlanar()) return null;
     
    @@ -294,7 +294,7 @@ public static List enumerateFaces(Graph graph) {
          * Each face becomes a node; two nodes are adjacent if their faces
          * share an edge.
          */
    -    public static DualGraph buildDualGraph(Graph graph) {
    +    public static DualGraph buildDualGraph(Graph graph) {
             List faces = enumerateFaces(graph);
             if (faces == null) return null;
     
    @@ -339,7 +339,7 @@ public static DualGraph buildDualGraph(Graph graph) {
          * Returns null if the graph is planar.
          */
         public static KuratowskiSubgraph findKuratowskiSubgraph(
    -            Graph graph) {
    +            Graph graph) {
             PlanarityResult pr = testPlanarity(graph);
             if (pr.isPlanar()) return null;
     
    @@ -361,7 +361,7 @@ public static KuratowskiSubgraph findKuratowskiSubgraph(
         /**
          * Generates a comprehensive planarity report.
          */
    -    public static PlanarityReport analyze(Graph graph) {
    +    public static PlanarityReport analyze(Graph graph) {
             PlanarityResult result = testPlanarity(graph);
             List faces = null;
             DualGraph dual = null;
    @@ -449,7 +449,7 @@ private static boolean isTriangleFree(Map> adj) {
         }
     
         /** Count connected components via BFS. */
    -    static int countComponents(Graph graph) {
    +    static int countComponents(Graph graph) {
             Set visited = new HashSet();
             int count = 0;
             for (String v : graph.getVertices()) {
    @@ -479,7 +479,7 @@ static int countComponents(Graph graph) {
          * Uses a proper graph minor / subdivision check approach.
          */
         private static boolean attemptPlanarEmbedding(
    -            Map> adj, Graph graph) {
    +            Map> adj, Graph graph) {
             // Decompose into biconnected components and test each
             List> bicomponents = findBiconnectedComponents(adj);
     
    @@ -841,7 +841,7 @@ private static int countDfsChildren(Map> adj,
          * neighbors by angle.
          */
         private static Map> buildPlanarEmbedding(
    -            Graph graph) {
    +            Graph graph) {
             Map> embedding = new LinkedHashMap>();
             Map> adj = GraphUtils.buildAdjacencyMap(graph);
             List vertices = new ArrayList(graph.getVertices());
    @@ -926,7 +926,7 @@ private static String makeEdgeKey(String a, String b) {
     
         /** Try to find a K₅ subdivision by looking for 5 high-degree vertices. */
         private static KuratowskiSubgraph findK5Subdivision(
    -            Map> adj, Graph graph) {
    +            Map> adj, Graph graph) {
             // Find vertices with degree >= 4 as candidates
             List candidates = new ArrayList();
             for (Map.Entry> entry : adj.entrySet()) {
    @@ -964,7 +964,7 @@ private static KuratowskiSubgraph findK5Subdivision(
     
         /** Try to find a K₃,₃ subdivision. */
         private static KuratowskiSubgraph findK33Subdivision(
    -            Map> adj, Graph graph) {
    +            Map> adj, Graph graph) {
             List candidates = new ArrayList();
             for (Map.Entry> entry : adj.entrySet()) {
                 if (entry.getValue().size() >= 3) {
    diff --git a/Gvisual/src/gvisual/ResiliencePanelController.java b/Gvisual/src/gvisual/ResiliencePanelController.java
    index c6f6d25..453204e 100644
    --- a/Gvisual/src/gvisual/ResiliencePanelController.java
    +++ b/Gvisual/src/gvisual/ResiliencePanelController.java
    @@ -24,7 +24,7 @@ public class ResiliencePanelController {
         private final JLabel summaryLabel;
         private final JLabel detailsLabel;
     
    -    private final Supplier> graphSupplier;
    +    private final Supplier> graphSupplier;
         private final JFrame parentFrame;
         private GraphResilienceAnalyzer lastAnalyzer;
     
    @@ -32,7 +32,7 @@ public class ResiliencePanelController {
          * @param graphSupplier supplies the current graph (may return null)
          * @param parentFrame   parent frame for dialogs
          */
    -    public ResiliencePanelController(Supplier> graphSupplier,
    +    public ResiliencePanelController(Supplier> graphSupplier,
                                          JFrame parentFrame) {
             this.graphSupplier = graphSupplier;
             this.parentFrame = parentFrame;
    @@ -84,7 +84,7 @@ public GraphResilienceAnalyzer getLastAnalyzer() {
         // ---- Analysis ----
     
         private void runAnalysis() {
    -        Graph g = graphSupplier.get();
    +        Graph g = graphSupplier.get();
             if (g == null || g.getVertexCount() == 0) {
                 summaryLabel.setText("No graph loaded.");
                 return;
    diff --git a/Gvisual/src/gvisual/RichClubAnalyzer.java b/Gvisual/src/gvisual/RichClubAnalyzer.java
    index 0a13c26..e230c7a 100644
    --- a/Gvisual/src/gvisual/RichClubAnalyzer.java
    +++ b/Gvisual/src/gvisual/RichClubAnalyzer.java
    @@ -40,7 +40,7 @@
      */
     public class RichClubAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private final Random random;
     
         /**
    @@ -48,7 +48,7 @@ public class RichClubAnalyzer {
          * @param graph the JUNG graph to analyze
          * @throws IllegalArgumentException if graph is null or empty
          */
    -    public RichClubAnalyzer(Graph graph) {
    +    public RichClubAnalyzer(Graph graph) {
             this(graph, new Random(42));
         }
     
    @@ -57,7 +57,7 @@ public RichClubAnalyzer(Graph graph) {
          * @param graph the JUNG graph to analyze
          * @param random random number generator for rewiring
          */
    -    public RichClubAnalyzer(Graph graph, Random random) {
    +    public RichClubAnalyzer(Graph graph, Random random) {
             if (graph == null) throw new IllegalArgumentException("Graph must not be null");
             if (graph.getVertexCount() == 0) throw new IllegalArgumentException("Graph must not be empty");
             if (random == null) throw new IllegalArgumentException("Random must not be null");
    @@ -191,13 +191,13 @@ public double internalEdgeFraction(int k) {
          */
         public double degreeAssortativity() {
             Map degrees = computeDegrees();
    -        Collection edges = graph.getEdges();
    +        Collection edges = graph.getEdges();
             if (edges.isEmpty()) return 0.0;
     
             double sumXY = 0, sumX = 0, sumY = 0, sumX2 = 0, sumY2 = 0;
             int m = 0;
     
    -        for (edge e : edges) {
    +        for (Edge e : edges) {
                 Collection endpoints = graph.getIncidentVertices(e);
                 if (endpoints == null || endpoints.size() != 2) continue;
                 Iterator it = endpoints.iterator();
    @@ -302,7 +302,7 @@ private int maxDegree() {
     
         private int countInternalEdges(Set memberSet) {
             int count = 0;
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection endpoints = graph.getIncidentVertices(e);
                 if (endpoints == null || endpoints.size() != 2) continue;
                 Iterator it = endpoints.iterator();
    diff --git a/Gvisual/src/gvisual/ShortestPathFinder.java b/Gvisual/src/gvisual/ShortestPathFinder.java
    index 8af7497..2e44183 100644
    --- a/Gvisual/src/gvisual/ShortestPathFinder.java
    +++ b/Gvisual/src/gvisual/ShortestPathFinder.java
    @@ -15,7 +15,7 @@
      */
     public class ShortestPathFinder {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /**
          * Creates a new ShortestPathFinder for the given graph.
    @@ -23,7 +23,7 @@ public class ShortestPathFinder {
          * @param graph the JUNG graph to search
          * @throws IllegalArgumentException if graph is null
          */
    -    public ShortestPathFinder(Graph graph) {
    +    public ShortestPathFinder(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -36,7 +36,7 @@ public ShortestPathFinder(Graph graph) {
          */
         public static class PathResult {
             private final List vertices;
    -        private final List edges;
    +        private final List edges;
             private final double totalWeight;
     
             /**
    @@ -44,9 +44,9 @@ public static class PathResult {
              * @param edges    ordered list of edges along the path
              * @param totalWeight sum of edge weights along the path
              */
    -        public PathResult(List vertices, List edges, double totalWeight) {
    +        public PathResult(List vertices, List edges, double totalWeight) {
                 this.vertices = Collections.unmodifiableList(new ArrayList(vertices));
    -            this.edges = Collections.unmodifiableList(new ArrayList(edges));
    +            this.edges = Collections.unmodifiableList(new ArrayList(edges));
                 this.totalWeight = totalWeight;
             }
     
    @@ -56,7 +56,7 @@ public List getVertices() {
             }
     
             /** Ordered edges from source to target. */
    -        public List getEdges() {
    +        public List getEdges() {
                 return edges;
             }
     
    @@ -108,7 +108,7 @@ public PathResult findShortestByHops(String source, String target) {
     
             // BFS
             Map predecessor = new HashMap();
    -        Map predecessorEdge = new HashMap();
    +        Map predecessorEdge = new HashMap();
             Queue queue = new LinkedList();
     
             predecessor.put(source, null);
    @@ -121,7 +121,7 @@ public PathResult findShortestByHops(String source, String target) {
                     return buildPath(source, target, predecessor, predecessorEdge);
                 }
     
    -            for (edge e : graph.getIncidentEdges(current)) {
    +            for (Edge e : graph.getIncidentEdges(current)) {
                     String neighbor = getOtherEnd(e, current);
                     if (neighbor != null && !predecessor.containsKey(neighbor)) {
                         predecessor.put(neighbor, current);
    @@ -164,7 +164,7 @@ public PathResult findShortestByWeight(String source, String target) {
             // at insertion time. Stale entries are skipped via the visited set.
             final Map dist = new HashMap();
             Map predecessor = new HashMap();
    -        Map predecessorEdge = new HashMap();
    +        Map predecessorEdge = new HashMap();
     
             PriorityQueue pq = new PriorityQueue(11, (double[] a, double[] b) -> {
                     return Double.compare(a[0], b[0]);
    @@ -195,7 +195,7 @@ public PathResult findShortestByWeight(String source, String target) {
                     return buildPath(source, target, predecessor, predecessorEdge, true);
                 }
     
    -            for (edge e : graph.getIncidentEdges(current)) {
    +            for (Edge e : graph.getIncidentEdges(current)) {
                     String neighbor = getOtherEnd(e, current);
                     if (neighbor == null || visited.contains(neighbor)) continue;
     
    @@ -248,7 +248,7 @@ public Set getReachableVertices(String source) {
     
             while (!queue.isEmpty()) {
                 String current = queue.poll();
    -            for (edge e : graph.getIncidentEdges(current)) {
    +            for (Edge e : graph.getIncidentEdges(current)) {
                     String neighbor = getOtherEnd(e, current);
                     if (neighbor != null && !reachable.contains(neighbor)) {
                         reachable.add(neighbor);
    @@ -282,7 +282,7 @@ public boolean areConnected(String source, String target) {
     
             while (!queue.isEmpty()) {
                 String current = queue.poll();
    -            for (edge e : graph.getIncidentEdges(current)) {
    +            for (Edge e : graph.getIncidentEdges(current)) {
                     String neighbor = getOtherEnd(e, current);
                     if (neighbor != null && !visited.contains(neighbor)) {
                         if (neighbor.equals(target)) return true;
    @@ -307,13 +307,13 @@ private void validateVertex(String vertex, String name) {
             }
         }
     
    -    private String getOtherEnd(edge e, String current) {
    +    private String getOtherEnd(Edge e, String current) {
             return GraphUtils.getOtherEnd(e, current);
         }
     
         private PathResult buildPath(String source, String target,
                                      Map predecessor,
    -                                 Map predecessorEdge) {
    +                                 Map predecessorEdge) {
             return buildPath(source, target, predecessor, predecessorEdge, false);
         }
     
    @@ -326,10 +326,10 @@ private PathResult buildPath(String source, String target,
          */
         private PathResult buildPath(String source, String target,
                                      Map predecessor,
    -                                 Map predecessorEdge,
    +                                 Map predecessorEdge,
                                      boolean normalizeZeroWeights) {
             List vertices = new ArrayList();
    -        List edges = new ArrayList();
    +        List edges = new ArrayList();
             double totalWeight = 0;
     
             String current = target;
    diff --git a/Gvisual/src/gvisual/SignedGraphAnalyzer.java b/Gvisual/src/gvisual/SignedGraphAnalyzer.java
    index 2fd1509..ef88544 100644
    --- a/Gvisual/src/gvisual/SignedGraphAnalyzer.java
    +++ b/Gvisual/src/gvisual/SignedGraphAnalyzer.java
    @@ -38,7 +38,7 @@
      */
     public class SignedGraphAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /**
          * Constructs an analyzer for the given graph.
    @@ -48,7 +48,7 @@ public class SignedGraphAnalyzer {
          * @param graph the graph to analyze
          * @throws IllegalArgumentException if graph is null
          */
    -    public SignedGraphAnalyzer(Graph graph) {
    +    public SignedGraphAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -61,7 +61,7 @@ public SignedGraphAnalyzer(Graph graph) {
          * @param e the edge
          * @return true if edge is negative (weight < 0 or label is "-"/"negative")
          */
    -    public boolean isNegative(edge e) {
    +    public boolean isNegative(Edge e) {
             if (e.getWeight() < 0) return true;
             String label = e.getLabel();
             return label != null && (label.equals("-") || label.equalsIgnoreCase("negative"));
    @@ -73,7 +73,7 @@ public boolean isNegative(edge e) {
          * @param e the edge
          * @return true if edge is positive
          */
    -    public boolean isPositive(edge e) {
    +    public boolean isPositive(Edge e) {
             return !isNegative(e);
         }
     
    @@ -85,7 +85,7 @@ public boolean isPositive(edge e) {
          */
         public int countPositiveEdges() {
             int count = 0;
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 if (isPositive(e)) count++;
             }
             return count;
    @@ -97,7 +97,7 @@ public int countPositiveEdges() {
          */
         public int countNegativeEdges() {
             int count = 0;
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 if (isNegative(e)) count++;
             }
             return count;
    @@ -123,13 +123,13 @@ public double negativityRatio() {
         public Map vertexPolarization() {
             Map result = new LinkedHashMap<>();
             for (String v : graph.getVertices()) {
    -            Collection incident = graph.getIncidentEdges(v);
    +            Collection incident = graph.getIncidentEdges(v);
                 if (incident == null || incident.isEmpty()) {
                     result.put(v, 0.0);
                     continue;
                 }
                 long negCount = 0;
    -            for (edge e : incident) {
    +            for (Edge e : incident) {
                     if (isNegative(e)) negCount++;
                 }
                 result.put(v, (double) negCount / incident.size());
    @@ -224,12 +224,12 @@ public TriangleCensus triangleCensus() {
     
             // Build adjacency for fast lookup
             Map> adj = new HashMap<>();
    -        Map> edgeMap = new HashMap<>();
    +        Map> edgeMap = new HashMap<>();
             for (String v : vertices) {
                 adj.put(v, new HashSet<>());
                 edgeMap.put(v, new HashMap<>());
             }
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection endpoints = graph.getEndpoints(e);
                 Iterator it = endpoints.iterator();
                 String u = it.next();
    @@ -285,7 +285,7 @@ public boolean isStronglyBalanced() {
     
             // Build adjacency
             Map> adj = buildAdjacency();
    -        Map> edgeMap = buildEdgeMap();
    +        Map> edgeMap = buildEdgeMap();
     
             for (String start : vertices) {
                 if (color.containsKey(start)) continue;
    @@ -332,9 +332,9 @@ public boolean isWeaklyBalanced() {
             for (String v : graph.getVertices()) {
                 posAdj.put(v, new ArrayList<>());
             }
    -        Map> edgeMap = buildEdgeMap();
    +        Map> edgeMap = buildEdgeMap();
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 if (isPositive(e)) {
                     Collection eps = graph.getEndpoints(e);
                     Iterator it = eps.iterator();
    @@ -365,7 +365,7 @@ public boolean isWeaklyBalanced() {
             }
     
             // Check that all negative edges go between different components
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 if (isNegative(e)) {
                     Collection eps = graph.getEndpoints(e);
                     Iterator it = eps.iterator();
    @@ -399,7 +399,7 @@ public List> findCoalitions() {
         private List> findStrongCoalitions() {
             Map color = new HashMap<>();
             Map> adj = buildAdjacency();
    -        Map> edgeMap = buildEdgeMap();
    +        Map> edgeMap = buildEdgeMap();
     
             for (String start : graph.getVertices()) {
                 if (color.containsKey(start)) continue;
    @@ -432,7 +432,7 @@ private List> findWeakCoalitions() {
             for (String v : graph.getVertices()) {
                 posAdj.put(v, new ArrayList<>());
             }
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 if (isPositive(e)) {
                     Collection eps = graph.getEndpoints(e);
                     Iterator it = eps.iterator();
    @@ -495,7 +495,7 @@ private int exactFrustration(List vertices) {
             Map idx = new HashMap<>();
             for (int i = 0; i < n; i++) idx.put(vertices.get(i), i);
     
    -        Map> edgeMap = buildEdgeMap();
    +        Map> edgeMap = buildEdgeMap();
             Map> adj = buildAdjacency();
     
             int bestFrustration = graph.getEdgeCount(); // worst case
    @@ -504,7 +504,7 @@ private int exactFrustration(List vertices) {
             int limit = 1 << (n - 1);
             for (int mask = 0; mask < limit; mask++) {
                 int frustration = 0;
    -            for (edge e : graph.getEdges()) {
    +            for (Edge e : graph.getEdges()) {
                     Collection eps = graph.getEndpoints(e);
                     Iterator it = eps.iterator();
                     String u = it.next();
    @@ -533,7 +533,7 @@ private int greedyFrustration(List vertices) {
             // Greedy: start with BFS coloring, count frustrated edges
             Map color = new HashMap<>();
             Map> adj = buildAdjacency();
    -        Map> edgeMap = buildEdgeMap();
    +        Map> edgeMap = buildEdgeMap();
     
             for (String start : vertices) {
                 if (color.containsKey(start)) continue;
    @@ -553,7 +553,7 @@ private int greedyFrustration(List vertices) {
             }
     
             int frustration = 0;
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection eps = graph.getEndpoints(e);
                 Iterator it = eps.iterator();
                 String u = it.next();
    @@ -573,13 +573,13 @@ private int greedyFrustration(List vertices) {
          *
          * @return list of frustrated edges
          */
    -    public List findFrustratedEdges() {
    +    public List findFrustratedEdges() {
             if (graph.getEdgeCount() == 0) return Collections.emptyList();
     
             Map color = computePartition();
    -        List frustrated = new ArrayList<>();
    +        List frustrated = new ArrayList<>();
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection eps = graph.getEndpoints(e);
                 Iterator it = eps.iterator();
                 String u = it.next();
    @@ -596,7 +596,7 @@ public List findFrustratedEdges() {
         private Map computePartition() {
             Map color = new HashMap<>();
             Map> adj = buildAdjacency();
    -        Map> edgeMap = buildEdgeMap();
    +        Map> edgeMap = buildEdgeMap();
     
             for (String start : graph.getVertices()) {
                 if (color.containsKey(start)) continue;
    @@ -639,7 +639,7 @@ public int predictSign(String u, String v) {
                 throw new IllegalArgumentException("Vertex not found: " + v);
             }
     
    -        Map> edgeMap = buildEdgeMap();
    +        Map> edgeMap = buildEdgeMap();
             Set neighborsU = new HashSet<>(edgeMap.getOrDefault(u, Collections.emptyMap()).keySet());
             Set neighborsV = new HashSet<>(edgeMap.getOrDefault(v, Collections.emptyMap()).keySet());
     
    @@ -771,7 +771,7 @@ private Map> buildAdjacency() {
             for (String v : graph.getVertices()) {
                 adj.put(v, new ArrayList<>());
             }
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection eps = graph.getEndpoints(e);
                 Iterator it = eps.iterator();
                 String u = it.next();
    @@ -782,12 +782,12 @@ private Map> buildAdjacency() {
             return adj;
         }
     
    -    private Map> buildEdgeMap() {
    -        Map> edgeMap = new HashMap<>();
    +    private Map> buildEdgeMap() {
    +        Map> edgeMap = new HashMap<>();
             for (String v : graph.getVertices()) {
                 edgeMap.put(v, new HashMap<>());
             }
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection eps = graph.getEndpoints(e);
                 Iterator it = eps.iterator();
                 String u = it.next();
    diff --git a/Gvisual/src/gvisual/SmallWorldAnalyzer.java b/Gvisual/src/gvisual/SmallWorldAnalyzer.java
    index 71a839a..785bf48 100644
    --- a/Gvisual/src/gvisual/SmallWorldAnalyzer.java
    +++ b/Gvisual/src/gvisual/SmallWorldAnalyzer.java
    @@ -47,7 +47,7 @@
      */
     public class SmallWorldAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private boolean computed;
     
         // ── Results ─────────────────────────────────────────────────────
    @@ -69,7 +69,7 @@ public class SmallWorldAnalyzer {
          * @param graph a JUNG undirected graph
          * @throws IllegalArgumentException if graph is null
          */
    -    public SmallWorldAnalyzer(Graph graph) {
    +    public SmallWorldAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    diff --git a/Gvisual/src/gvisual/SpectralAnalyzer.java b/Gvisual/src/gvisual/SpectralAnalyzer.java
    index 0235a72..9d225e1 100644
    --- a/Gvisual/src/gvisual/SpectralAnalyzer.java
    +++ b/Gvisual/src/gvisual/SpectralAnalyzer.java
    @@ -49,7 +49,7 @@ public class SpectralAnalyzer {
         private static final double EPSILON = 1e-10;
         private static final int MAX_SWEEPS = 100;
     
    -    private final Graph graph;
    +    private final Graph graph;
         private boolean computed;
     
         // Ordered vertex list (defines row/column mapping)
    @@ -76,7 +76,7 @@ public class SpectralAnalyzer {
          * @param graph the JUNG graph to analyse
          * @throws IllegalArgumentException if graph is null
          */
    -    public SpectralAnalyzer(Graph graph) {
    +    public SpectralAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    diff --git a/Gvisual/src/gvisual/SteinerTreeAnalyzer.java b/Gvisual/src/gvisual/SteinerTreeAnalyzer.java
    index d909c52..881c43c 100644
    --- a/Gvisual/src/gvisual/SteinerTreeAnalyzer.java
    +++ b/Gvisual/src/gvisual/SteinerTreeAnalyzer.java
    @@ -48,10 +48,10 @@
      */
     public class SteinerTreeAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private int syntheticEdgeId = 0;
     
    -    public SteinerTreeAnalyzer(Graph graph) {
    +    public SteinerTreeAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -415,7 +415,7 @@ public SteinerTreeResult exact(Set terminals) {
             for (double[] row : dist) Arrays.fill(row, Double.MAX_VALUE / 2);
             for (int[] row : next) Arrays.fill(row, -1);
             for (int i = 0; i < V; i++) { dist[i][i] = 0; next[i][i] = i; }
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection endpoints = graph.getEndpoints(e);
                 Iterator eit = endpoints.iterator();
                 String u = eit.next(), v = eit.next();
    diff --git a/Gvisual/src/gvisual/StronglyConnectedComponentsAnalyzer.java b/Gvisual/src/gvisual/StronglyConnectedComponentsAnalyzer.java
    index f34ab74..fd41c22 100644
    --- a/Gvisual/src/gvisual/StronglyConnectedComponentsAnalyzer.java
    +++ b/Gvisual/src/gvisual/StronglyConnectedComponentsAnalyzer.java
    @@ -37,7 +37,7 @@
      */
     public class StronglyConnectedComponentsAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
     
         /**
          * Create a new SCC analyzer for the given graph.
    @@ -45,7 +45,7 @@ public class StronglyConnectedComponentsAnalyzer {
          * @param graph the JUNG graph to analyze (must not be null)
          * @throws IllegalArgumentException if graph is null
          */
    -    public StronglyConnectedComponentsAnalyzer(Graph graph) {
    +    public StronglyConnectedComponentsAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -86,12 +86,12 @@ public String toString() {
         public static class SCCResult {
             private final List components;
             private final Map vertexToComponent;
    -        private final Graph condensation;
    -        private final List bridgeEdges;
    +        private final Graph condensation;
    +        private final List bridgeEdges;
             private final String algorithm;
     
             public SCCResult(List components, Map vertexToComponent,
    -                         Graph condensation, List bridgeEdges, String algorithm) {
    +                         Graph condensation, List bridgeEdges, String algorithm) {
                 this.components = Collections.unmodifiableList(components);
                 this.vertexToComponent = Collections.unmodifiableMap(vertexToComponent);
                 this.condensation = condensation;
    @@ -102,8 +102,8 @@ public SCCResult(List components, Map vertexToCompon
             public List getComponents() { return components; }
             public int getComponentCount() { return components.size(); }
             public Map getVertexToComponent() { return vertexToComponent; }
    -        public Graph getCondensation() { return condensation; }
    -        public List getBridgeEdges() { return bridgeEdges; }
    +        public Graph getCondensation() { return condensation; }
    +        public List getBridgeEdges() { return bridgeEdges; }
             public String getAlgorithm() { return algorithm; }
     
             /** Get the component containing a specific vertex. */
    @@ -276,7 +276,7 @@ public SCCResult kosaraju() {
             for (String v : graph.getVertices()) {
                 transpose.put(v, new ArrayList());
             }
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String src = getSource(e);
                 String dst = getDest(e);
                 if (src != null && dst != null) {
    @@ -363,16 +363,16 @@ private SCCResult buildResult(List> rawComponents, String algorithm)
             }
     
             // Build condensation DAG
    -        Graph condensation = new DirectedSparseGraph();
    +        Graph condensation = new DirectedSparseGraph();
             for (Component c : components) {
                 condensation.addVertex("SCC-" + c.getId());
             }
     
    -        List bridgeEdges = new ArrayList();
    +        List bridgeEdges = new ArrayList();
             Set condensationEdgeSet = new HashSet();
             int edgeId = 0;
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String src = getSource(e);
                 String dst = getDest(e);
                 if (src == null || dst == null) continue;
    @@ -385,7 +385,7 @@ private SCCResult buildResult(List> rawComponents, String algorithm)
                     String key = srcComp + "->" + dstComp;
                     if (!condensationEdgeSet.contains(key)) {
                         condensationEdgeSet.add(key);
    -                    edge ce = new edge("bridge", "SCC-" + srcComp, "SCC-" + dstComp);
    +                    edge ce = new Edge("bridge", "SCC-" + srcComp, "SCC-" + dstComp);
                         ce.setLabel("ce" + edgeId++);
                         condensation.addEdge(ce, "SCC-" + srcComp, "SCC-" + dstComp);
                     }
    @@ -474,9 +474,9 @@ public int minEdgesToStronglyConnect(SCCResult result) {
     
         private List getSuccessors(String v) {
             List result = new ArrayList();
    -        Collection outEdges = graph.getOutEdges(v);
    +        Collection outEdges = graph.getOutEdges(v);
             if (outEdges != null) {
    -            for (edge e : outEdges) {
    +            for (Edge e : outEdges) {
                     String dest = getDest(e);
                     if (dest != null && !dest.equals(v)) {
                         result.add(dest);
    @@ -489,11 +489,11 @@ private List getSuccessors(String v) {
             return result;
         }
     
    -    private String getSource(edge e) {
    +    private String getSource(Edge e) {
             return e.getVertex1();
         }
     
    -    private String getDest(edge e) {
    +    private String getDest(Edge e) {
             return e.getVertex2();
         }
     }
    diff --git a/Gvisual/src/gvisual/StructuralHoleAnalyzer.java b/Gvisual/src/gvisual/StructuralHoleAnalyzer.java
    index 2f40a52..35e3759 100644
    --- a/Gvisual/src/gvisual/StructuralHoleAnalyzer.java
    +++ b/Gvisual/src/gvisual/StructuralHoleAnalyzer.java
    @@ -50,7 +50,7 @@
      */
     public class StructuralHoleAnalyzer {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private final Map> neighborCache;
     
         /**
    @@ -59,7 +59,7 @@ public class StructuralHoleAnalyzer {
          * @param graph the JUNG graph to analyze (must not be null)
          * @throws IllegalArgumentException if graph is null
          */
    -    public StructuralHoleAnalyzer(Graph graph) {
    +    public StructuralHoleAnalyzer(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -289,7 +289,7 @@ public List findBridgingEdges() {
             List bridges = new ArrayList<>();
             Set seen = new HashSet<>();
     
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 Collection endpoints = graph.getEndpoints(e);
                 if (endpoints == null || endpoints.size() != 2) continue;
     
    diff --git a/Gvisual/src/gvisual/SubgraphExtractor.java b/Gvisual/src/gvisual/SubgraphExtractor.java
    index ead84e4..0e13eb6 100644
    --- a/Gvisual/src/gvisual/SubgraphExtractor.java
    +++ b/Gvisual/src/gvisual/SubgraphExtractor.java
    @@ -50,8 +50,8 @@
      */
     public class SubgraphExtractor {
     
    -    private final Graph sourceGraph;
    -    private final List allEdges;
    +    private final Graph sourceGraph;
    +    private final List allEdges;
     
         // Filter state
         private final Set allowedEdgeTypes = new HashSet<>();
    @@ -72,7 +72,7 @@ public class SubgraphExtractor {
          * @param graph    the source JUNG graph
          * @param allEdges the full edge list (used for filtering before graph insertion)
          */
    -    public SubgraphExtractor(Graph graph, List allEdges) {
    +    public SubgraphExtractor(Graph graph, List allEdges) {
             if (graph == null) throw new IllegalArgumentException("graph must not be null");
             if (allEdges == null) throw new IllegalArgumentException("allEdges must not be null");
             this.sourceGraph = graph;
    @@ -191,8 +191,8 @@ public Result extract() {
             Set candidateNodes = determineCandidateNodes();
     
             // Step 2: Filter edges
    -        List filteredEdges = new ArrayList<>();
    -        for (edge e : allEdges) {
    +        List filteredEdges = new ArrayList<>();
    +        for (Edge e : allEdges) {
                 if (!candidateNodes.contains(e.getVertex1()) || !candidateNodes.contains(e.getVertex2())) {
                     continue;
                 }
    @@ -212,7 +212,7 @@ public Result extract() {
             }
     
             // Step 3: Build subgraph
    -        Graph subgraph = new UndirectedSparseGraph<>();
    +        Graph subgraph = new UndirectedSparseGraph<>();
     
             // Add all candidate nodes first (unless connectedOnly)
             if (!connectedOnly) {
    @@ -221,7 +221,7 @@ public Result extract() {
                 }
             }
     
    -        for (edge e : filteredEdges) {
    +        for (Edge e : filteredEdges) {
                 subgraph.addVertex(e.getVertex1());
                 subgraph.addVertex(e.getVertex2());
                 subgraph.addEdge(e, e.getVertex1(), e.getVertex2());
    @@ -302,12 +302,12 @@ private Set determineCandidateNodes() {
          * the filtered edge list, and summary statistics.
          */
         public static class Result {
    -        private final Graph graph;
    -        private final List edges;
    +        private final Graph graph;
    +        private final List edges;
             private final int originalNodeCount;
             private final int originalEdgeCount;
     
    -        Result(Graph graph, List edges,
    +        Result(Graph graph, List edges,
                    int originalNodeCount, int originalEdgeCount) {
                 this.graph = graph;
                 this.edges = Collections.unmodifiableList(new ArrayList<>(edges));
    @@ -316,12 +316,12 @@ public static class Result {
             }
     
             /** Returns the extracted subgraph. */
    -        public Graph getGraph() {
    +        public Graph getGraph() {
                 return graph;
             }
     
             /** Returns the filtered edges in the subgraph. */
    -        public List getEdges() {
    +        public List getEdges() {
                 return edges;
             }
     
    @@ -350,7 +350,7 @@ public double getEdgeRetention() {
             /** Returns a per-edge-type count breakdown. */
             public Map getEdgeTypeBreakdown() {
                 Map breakdown = new TreeMap<>();
    -            for (edge e : edges) {
    +            for (Edge e : edges) {
                     String type = e.getType();
                     EdgeType et = EdgeType.fromCode(type);
                     String label = et != null ? et.getDisplayLabel() : type;
    @@ -397,7 +397,7 @@ public void exportEdgeList(File file) throws IOException {
                 try (PrintWriter pw = new PrintWriter(
                         new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
                     pw.println("source,target,type,weight,label");
    -                for (edge e : edges) {
    +                for (Edge e : edges) {
                         pw.printf("%s,%s,%s,%.2f,%s%n",
                                 csvEscape(e.getVertex1()),
                                 csvEscape(e.getVertex2()),
    @@ -416,7 +416,7 @@ public void exportEdgeList(File file) throws IOException {
             public String exportEdgeListToString() {
                 StringBuilder sb = new StringBuilder();
                 sb.append("source,target,type,weight,label\n");
    -            for (edge e : edges) {
    +            for (Edge e : edges) {
                     sb.append(String.format("%s,%s,%s,%.2f,%s%n",
                             csvEscape(e.getVertex1()),
                             csvEscape(e.getVertex2()),
    diff --git a/Gvisual/src/gvisual/SubgraphPatternMatcher.java b/Gvisual/src/gvisual/SubgraphPatternMatcher.java
    index 463bb15..7a37ab4 100644
    --- a/Gvisual/src/gvisual/SubgraphPatternMatcher.java
    +++ b/Gvisual/src/gvisual/SubgraphPatternMatcher.java
    @@ -50,8 +50,8 @@
      */
     public class SubgraphPatternMatcher {
     
    -    private final Graph target;
    -    private final Graph pattern;
    +    private final Graph target;
    +    private final Graph pattern;
         private final boolean degreeConstrained;
         private final String edgeTypeFilter;
         private final int maxMatches;
    @@ -62,8 +62,8 @@ public class SubgraphPatternMatcher {
          * Fluent builder for configuring a SubgraphPatternMatcher.
          */
         public static class Builder {
    -        private final Graph target;
    -        private final Graph pattern;
    +        private final Graph target;
    +        private final Graph pattern;
             private boolean degreeConstrained = false;
             private String edgeTypeFilter = null;
             private int maxMatches = 10_000;
    @@ -77,8 +77,8 @@ public static class Builder {
              * @throws IllegalArgumentException if either is null or pattern is
              *                                  too small
              */
    -        public Builder(Graph target,
    -                       Graph pattern) {
    +        public Builder(Graph target,
    +                       Graph pattern) {
                 if (target == null) {
                     throw new IllegalArgumentException("Target graph must not be null");
                 }
    @@ -461,7 +461,7 @@ private Map> buildTargetAdjacency() {
             for (String v : target.getVertices()) {
                 adj.put(v, new HashSet<>());
             }
    -        for (edge e : target.getEdges()) {
    +        for (Edge e : target.getEdges()) {
                 if (edgeTypeFilter != null &&
                         !edgeTypeFilter.equals(e.getType())) {
                     continue;
    @@ -482,7 +482,7 @@ private Map> buildPatternAdjacency() {
             for (String v : pattern.getVertices()) {
                 adj.put(v, new HashSet<>());
             }
    -        for (edge e : pattern.getEdges()) {
    +        for (Edge e : pattern.getEdges()) {
                 String v1 = e.getVertex1();
                 String v2 = e.getVertex2();
                 if (v1 != null && v2 != null) {
    @@ -498,27 +498,27 @@ private Map> buildPatternAdjacency() {
         /**
          * Create a triangle pattern (3 mutually connected nodes).
          */
    -    public static Graph trianglePattern() {
    -        Graph g = new UndirectedSparseGraph<>();
    +    public static Graph trianglePattern() {
    +        Graph g = new UndirectedSparseGraph<>();
             g.addVertex("P0");
             g.addVertex("P1");
             g.addVertex("P2");
    -        g.addEdge(new edge(null, "P0", "P1"), "P0", "P1");
    -        g.addEdge(new edge(null, "P1", "P2"), "P1", "P2");
    -        g.addEdge(new edge(null, "P0", "P2"), "P0", "P2");
    +        g.addEdge(new Edge(null, "P0", "P1"), "P0", "P1");
    +        g.addEdge(new Edge(null, "P1", "P2"), "P1", "P2");
    +        g.addEdge(new Edge(null, "P0", "P2"), "P0", "P2");
             return g;
         }
     
         /**
          * Create a square/4-cycle pattern (C4).
          */
    -    public static Graph squarePattern() {
    -        Graph g = new UndirectedSparseGraph<>();
    +    public static Graph squarePattern() {
    +        Graph g = new UndirectedSparseGraph<>();
             for (int i = 0; i < 4; i++) g.addVertex("P" + i);
    -        g.addEdge(new edge(null, "P0", "P1"), "P0", "P1");
    -        g.addEdge(new edge(null, "P1", "P2"), "P1", "P2");
    -        g.addEdge(new edge(null, "P2", "P3"), "P2", "P3");
    -        g.addEdge(new edge(null, "P3", "P0"), "P3", "P0");
    +        g.addEdge(new Edge(null, "P0", "P1"), "P0", "P1");
    +        g.addEdge(new Edge(null, "P1", "P2"), "P1", "P2");
    +        g.addEdge(new Edge(null, "P2", "P3"), "P2", "P3");
    +        g.addEdge(new Edge(null, "P3", "P0"), "P3", "P0");
             return g;
         }
     
    @@ -528,14 +528,14 @@ public static Graph squarePattern() {
          *
          * @param k number of leaves (must be ≥ 2)
          */
    -    public static Graph starPattern(int k) {
    +    public static Graph starPattern(int k) {
             if (k < 2) throw new IllegalArgumentException("Star needs >= 2 leaves");
    -        Graph g = new UndirectedSparseGraph<>();
    +        Graph g = new UndirectedSparseGraph<>();
             g.addVertex("hub");
             for (int i = 0; i < k; i++) {
                 String leaf = "L" + i;
                 g.addVertex(leaf);
    -            g.addEdge(new edge(null, "hub", leaf), "hub", leaf);
    +            g.addEdge(new Edge(null, "hub", leaf), "hub", leaf);
             }
             return g;
         }
    @@ -545,12 +545,12 @@ public static Graph starPattern(int k) {
          *
          * @param n path length (edges), must be ≥ 1
          */
    -    public static Graph pathPattern(int n) {
    +    public static Graph pathPattern(int n) {
             if (n < 1) throw new IllegalArgumentException("Path length must be >= 1");
    -        Graph g = new UndirectedSparseGraph<>();
    +        Graph g = new UndirectedSparseGraph<>();
             for (int i = 0; i <= n; i++) g.addVertex("P" + i);
             for (int i = 0; i < n; i++) {
    -            g.addEdge(new edge(null, "P" + i, "P" + (i + 1)),
    +            g.addEdge(new Edge(null, "P" + i, "P" + (i + 1)),
                         "P" + i, "P" + (i + 1));
             }
             return g;
    @@ -560,15 +560,15 @@ public static Graph pathPattern(int n) {
          * Create a diamond pattern (K4 minus one edge: 4 nodes, 5 edges).
          * Shape: two triangles sharing an edge.
          */
    -    public static Graph diamondPattern() {
    -        Graph g = new UndirectedSparseGraph<>();
    +    public static Graph diamondPattern() {
    +        Graph g = new UndirectedSparseGraph<>();
             for (int i = 0; i < 4; i++) g.addVertex("P" + i);
             // P0-P1, P0-P2, P0-P3, P1-P2, P2-P3 (missing P1-P3)
    -        g.addEdge(new edge(null, "P0", "P1"), "P0", "P1");
    -        g.addEdge(new edge(null, "P0", "P2"), "P0", "P2");
    -        g.addEdge(new edge(null, "P0", "P3"), "P0", "P3");
    -        g.addEdge(new edge(null, "P1", "P2"), "P1", "P2");
    -        g.addEdge(new edge(null, "P2", "P3"), "P2", "P3");
    +        g.addEdge(new Edge(null, "P0", "P1"), "P0", "P1");
    +        g.addEdge(new Edge(null, "P0", "P2"), "P0", "P2");
    +        g.addEdge(new Edge(null, "P0", "P3"), "P0", "P3");
    +        g.addEdge(new Edge(null, "P1", "P2"), "P1", "P2");
    +        g.addEdge(new Edge(null, "P2", "P3"), "P2", "P3");
             return g;
         }
     
    @@ -576,17 +576,17 @@ public static Graph diamondPattern() {
          * Create a bowtie pattern (two triangles sharing one vertex: 5 nodes,
          * 6 edges).
          */
    -    public static Graph bowtiePattern() {
    -        Graph g = new UndirectedSparseGraph<>();
    +    public static Graph bowtiePattern() {
    +        Graph g = new UndirectedSparseGraph<>();
             for (int i = 0; i < 5; i++) g.addVertex("P" + i);
             // Triangle 1: P0-P1-P2
    -        g.addEdge(new edge(null, "P0", "P1"), "P0", "P1");
    -        g.addEdge(new edge(null, "P1", "P2"), "P1", "P2");
    -        g.addEdge(new edge(null, "P0", "P2"), "P0", "P2");
    +        g.addEdge(new Edge(null, "P0", "P1"), "P0", "P1");
    +        g.addEdge(new Edge(null, "P1", "P2"), "P1", "P2");
    +        g.addEdge(new Edge(null, "P0", "P2"), "P0", "P2");
             // Triangle 2: P0-P3-P4 (P0 is shared)
    -        g.addEdge(new edge(null, "P0", "P3"), "P0", "P3");
    -        g.addEdge(new edge(null, "P3", "P4"), "P3", "P4");
    -        g.addEdge(new edge(null, "P0", "P4"), "P0", "P4");
    +        g.addEdge(new Edge(null, "P0", "P3"), "P0", "P3");
    +        g.addEdge(new Edge(null, "P3", "P4"), "P3", "P4");
    +        g.addEdge(new Edge(null, "P0", "P4"), "P0", "P4");
             return g;
         }
     
    @@ -595,13 +595,13 @@ public static Graph bowtiePattern() {
          *
          * @param n number of nodes (must be ≥ 2)
          */
    -    public static Graph completePattern(int n) {
    +    public static Graph completePattern(int n) {
             if (n < 2) throw new IllegalArgumentException("Complete graph needs >= 2 nodes");
    -        Graph g = new UndirectedSparseGraph<>();
    +        Graph g = new UndirectedSparseGraph<>();
             for (int i = 0; i < n; i++) g.addVertex("P" + i);
             for (int i = 0; i < n; i++) {
                 for (int j = i + 1; j < n; j++) {
    -                g.addEdge(new edge(null, "P" + i, "P" + j),
    +                g.addEdge(new Edge(null, "P" + i, "P" + j),
                             "P" + i, "P" + j);
                 }
             }
    @@ -611,17 +611,17 @@ public static Graph completePattern(int n) {
         /**
          * Create a house pattern (square + triangle on top: 5 nodes, 6 edges).
          */
    -    public static Graph housePattern() {
    -        Graph g = new UndirectedSparseGraph<>();
    +    public static Graph housePattern() {
    +        Graph g = new UndirectedSparseGraph<>();
             for (int i = 0; i < 5; i++) g.addVertex("P" + i);
             // Square base: P0-P1-P2-P3
    -        g.addEdge(new edge(null, "P0", "P1"), "P0", "P1");
    -        g.addEdge(new edge(null, "P1", "P2"), "P1", "P2");
    -        g.addEdge(new edge(null, "P2", "P3"), "P2", "P3");
    -        g.addEdge(new edge(null, "P3", "P0"), "P3", "P0");
    +        g.addEdge(new Edge(null, "P0", "P1"), "P0", "P1");
    +        g.addEdge(new Edge(null, "P1", "P2"), "P1", "P2");
    +        g.addEdge(new Edge(null, "P2", "P3"), "P2", "P3");
    +        g.addEdge(new Edge(null, "P3", "P0"), "P3", "P0");
             // Roof triangle: P2-P4-P3
    -        g.addEdge(new edge(null, "P2", "P4"), "P2", "P4");
    -        g.addEdge(new edge(null, "P3", "P4"), "P3", "P4");
    +        g.addEdge(new Edge(null, "P2", "P4"), "P2", "P4");
    +        g.addEdge(new Edge(null, "P3", "P4"), "P3", "P4");
             return g;
         }
     }
    diff --git a/Gvisual/src/gvisual/SvgExporter.java b/Gvisual/src/gvisual/SvgExporter.java
    index 84a6939..be17ef9 100644
    --- a/Gvisual/src/gvisual/SvgExporter.java
    +++ b/Gvisual/src/gvisual/SvgExporter.java
    @@ -42,7 +42,7 @@
      */
     public class SvgExporter {
     
    -    private final Graph graph;
    +    private final Graph graph;
         private int width = 800;
         private int height = 600;
         private int margin = 60;
    @@ -82,7 +82,7 @@ public class SvgExporter {
          * @param graph the JUNG graph to export
          * @throws IllegalArgumentException if graph is null
          */
    -    public SvgExporter(Graph graph) {
    +    public SvgExporter(Graph graph) {
             if (graph == null) {
                 throw new IllegalArgumentException("Graph must not be null");
             }
    @@ -166,7 +166,7 @@ public String exportToString() {
                 maxDegree = Math.max(maxDegree, graph.degree(v));
             }
             float minWeight = Float.MAX_VALUE, maxWeight = Float.MIN_VALUE;
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 minWeight = Math.min(minWeight, e.getWeight());
                 maxWeight = Math.max(maxWeight, e.getWeight());
             }
    @@ -175,7 +175,7 @@ public String exportToString() {
     
             // Collect used edge types
             Set usedTypes = new LinkedHashSet<>();
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 if (e.getType() != null) usedTypes.add(e.getType());
             }
     
    @@ -234,7 +234,7 @@ public String exportToString() {
             // Edges (drawn first, beneath nodes)
             sb.append("  \n");
             Set emitted = new HashSet<>();
    -        for (edge e : graph.getEdges()) {
    +        for (Edge e : graph.getEdges()) {
                 String v1 = e.getVertex1();
                 String v2 = e.getVertex2();
                 String key = v1.compareTo(v2) < 0 ? v1 + "|" + v2 : v2 + "|" + v1;
    @@ -403,7 +403,7 @@ private Map computeLayout() {
                 }
     
                 // Attractive forces along edges
    -            for (edge e : graph.getEdges()) {
    +            for (Edge e : graph.getEdges()) {
                     Integer i = index.get(e.getVertex1());
                     Integer j = index.get(e.getVertex2());
                     if (i == null || j == null || i.equals(j)) continue;
    diff --git a/Gvisual/src/gvisual/TemporalGraph.java b/Gvisual/src/gvisual/TemporalGraph.java
    index d33d1f3..5fe5848 100644
    --- a/Gvisual/src/gvisual/TemporalGraph.java
    +++ b/Gvisual/src/gvisual/TemporalGraph.java
    @@ -7,7 +7,7 @@
     /**
      * A lightweight wrapper around a JUNG graph that provides time-windowed views
      * of the network. This enables temporal analysis without changing any existing
    - * analyzer — analyzers receive a normal {@code Graph} for a
    + * analyzer — analyzers receive a normal {@code Graph} for a
      * specific time window.
      *
      * 

    Supports three modes of temporal access:

    @@ -25,7 +25,7 @@ */ public class TemporalGraph { - private final Graph fullGraph; + private final Graph fullGraph; /** * Creates a TemporalGraph wrapping an existing JUNG graph. @@ -33,7 +33,7 @@ public class TemporalGraph { * @param graph the full graph containing edges with optional timestamps * @throws IllegalArgumentException if graph is null */ - public TemporalGraph(Graph graph) { + public TemporalGraph(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -45,7 +45,7 @@ public TemporalGraph(Graph graph) { * * @return the full graph */ - public Graph getFullGraph() { + public Graph getFullGraph() { return fullGraph; } @@ -57,9 +57,9 @@ public Graph getFullGraph() { * @param time the point in time (epoch millis) * @return a new graph containing only edges active at {@code time} */ - public Graph snapshotAt(long time) { - Graph snapshot = new UndirectedSparseGraph<>(); - for (edge e : fullGraph.getEdges()) { + public Graph snapshotAt(long time) { + Graph snapshot = new UndirectedSparseGraph<>(); + for (Edge e : fullGraph.getEdges()) { if (e.isActiveAt(time)) { addEdgeToGraph(snapshot, e); } @@ -76,13 +76,13 @@ public Graph snapshotAt(long time) { * @return a new graph containing only edges active during the window * @throws IllegalArgumentException if start > end */ - public Graph windowBetween(long start, long end) { + public Graph windowBetween(long start, long end) { if (start > end) { throw new IllegalArgumentException( "Start time must not be after end time: " + start + " > " + end); } - Graph window = new UndirectedSparseGraph<>(); - for (edge e : fullGraph.getEdges()) { + Graph window = new UndirectedSparseGraph<>(); + for (Edge e : fullGraph.getEdges()) { if (e.isActiveDuring(start, end)) { addEdgeToGraph(window, e); } @@ -98,7 +98,7 @@ public Graph windowBetween(long start, long end) { */ public List getTimePoints() { TreeSet times = new TreeSet<>(); - for (edge e : fullGraph.getEdges()) { + for (Edge e : fullGraph.getEdges()) { if (e.getTimestamp() != null) { times.add(e.getTimestamp()); } @@ -128,7 +128,7 @@ public int getTimePointCount() { * @throws IllegalArgumentException if windowCount < 1 * @throws IllegalStateException if the graph has no timestamped edges */ - public List>> generateWindows(int windowCount) { + public List>> generateWindows(int windowCount) { if (windowCount < 1) { throw new IllegalArgumentException("windowCount must be at least 1"); } @@ -142,7 +142,7 @@ public List>> generateWindows(int windowCoun long maxTime = times.get(times.size() - 1); long windowWidth = Math.max(1, (maxTime - minTime + 1) / windowCount); - List>> windows = new ArrayList<>(); + List>> windows = new ArrayList<>(); for (int i = 0; i < windowCount; i++) { long wStart = minTime + (i * windowWidth); long wEnd = (i == windowCount - 1) ? maxTime : wStart + windowWidth - 1; @@ -156,7 +156,7 @@ public List>> generateWindows(int windowCoun * Adds an edge and its endpoints to a graph, skipping if the edge * or vertices already exist. */ - private void addEdgeToGraph(Graph graph, edge e) { + private void addEdgeToGraph(Graph graph, edge e) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); if (!graph.containsVertex(v1)) graph.addVertex(v1); diff --git a/Gvisual/src/gvisual/ToolbarBuilder.java b/Gvisual/src/gvisual/ToolbarBuilder.java index b83c22f..687dc84 100644 --- a/Gvisual/src/gvisual/ToolbarBuilder.java +++ b/Gvisual/src/gvisual/ToolbarBuilder.java @@ -36,16 +36,16 @@ public final class ToolbarBuilder { /** Callback interface for the host to supply live graph + edge data. */ public interface GraphContext { /** Current graph (may be null before a file is loaded). */ - Graph getGraph(); + Graph getGraph(); /** Current visualization viewer. */ - VisualizationViewer getVisualizationViewer(); + VisualizationViewer getVisualizationViewer(); /** Current timestamp label used in export filenames. */ String getTimestamp(); /** Collect all edges across every category. */ - List collectAllEdges(); + List collectAllEdges(); } private ToolbarBuilder() { /* utility */ } @@ -279,7 +279,7 @@ private static void addDiffHtmlButton(JPanel panel, JFrame owner, GraphContext c "
    Diff HTML
    Compare two
    graph snapshots
    in interactive
    HTML diff view
    "); btn.setPreferredSize(new Dimension(140, 100)); btn.addActionListener(e -> { - Graph g = ctx.getGraph(); + Graph g = ctx.getGraph(); if (g == null || g.getVertexCount() == 0) { JOptionPane.showMessageDialog(owner, "Load a graph first.", "No Graph", JOptionPane.WARNING_MESSAGE); @@ -291,7 +291,7 @@ private static void addDiffHtmlButton(JPanel panel, JFrame owner, GraphContext c try { GraphFileParser.ParseResult parseResult = GraphFileParser.parse(fc.getSelectedFile().getAbsolutePath()); - Graph graphB = parseResult.getGraph(); + Graph graphB = parseResult.getGraph(); GraphDiffHtmlExporter exporter = new GraphDiffHtmlExporter(g, graphB); exporter.setTitle("Graph Diff: current vs " + fc.getSelectedFile().getName()); exporter.setLabelA("Current Graph"); diff --git a/Gvisual/src/gvisual/TopologicalSortAnalyzer.java b/Gvisual/src/gvisual/TopologicalSortAnalyzer.java index 3574df4..ba5ac02 100644 --- a/Gvisual/src/gvisual/TopologicalSortAnalyzer.java +++ b/Gvisual/src/gvisual/TopologicalSortAnalyzer.java @@ -31,7 +31,7 @@ */ public class TopologicalSortAnalyzer { - private final Graph graph; + private final Graph graph; /** * Create a new analyzer for the given graph. @@ -39,7 +39,7 @@ public class TopologicalSortAnalyzer { * @param graph the JUNG graph to analyze (must not be null) * @throws IllegalArgumentException if graph is null */ - public TopologicalSortAnalyzer(Graph graph) { + public TopologicalSortAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -117,18 +117,18 @@ public TopologicalSortResult(boolean isDAG, List sortedOrder, */ public static class CycleInfo { private final List vertices; - private final List edges; + private final List edges; - public CycleInfo(List vertices, List edges) { + public CycleInfo(List vertices, List edges) { this.vertices = Collections.unmodifiableList(new ArrayList(vertices)); - this.edges = Collections.unmodifiableList(new ArrayList(edges)); + this.edges = Collections.unmodifiableList(new ArrayList(edges)); } /** Vertices forming the cycle, in traversal order. */ public List getVertices() { return vertices; } /** Edges forming the cycle. */ - public List getEdges() { return edges; } + public List getEdges() { return edges; } /** Number of vertices in the cycle. */ public int size() { return vertices.size(); } @@ -521,7 +521,7 @@ private void dfsCycleDetect(String v, Map> successors, if (color.get(w) == 1) { // Back edge found → extract cycle List cycleVertices = new ArrayList(); - List cycleEdges = new ArrayList(); + List cycleEdges = new ArrayList(); // Find w in the path and extract from there boolean found = false; @@ -569,7 +569,7 @@ private boolean isDuplicateCycle(List existing, List newCycle * Find an edge from vertex1 to vertex2 in the graph. */ private edge findEdge(String from, String to) { - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { if (from.equals(e.getVertex1()) && to.equals(e.getVertex2())) { return e; } diff --git a/Gvisual/src/gvisual/TournamentAnalyzer.java b/Gvisual/src/gvisual/TournamentAnalyzer.java index 24e2cdb..da29840 100644 --- a/Gvisual/src/gvisual/TournamentAnalyzer.java +++ b/Gvisual/src/gvisual/TournamentAnalyzer.java @@ -43,7 +43,7 @@ */ public class TournamentAnalyzer { - private final Graph graph; + private final Graph graph; private final List vertices; private final Map> beats; // u → set of v where u beats v @@ -53,7 +53,7 @@ public class TournamentAnalyzer { * @param graph the JUNG graph to analyze (must not be null) * @throws IllegalArgumentException if graph is null */ - public TournamentAnalyzer(Graph graph) { + public TournamentAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } diff --git a/Gvisual/src/gvisual/TreeAnalyzer.java b/Gvisual/src/gvisual/TreeAnalyzer.java index e97f579..c8b5c12 100644 --- a/Gvisual/src/gvisual/TreeAnalyzer.java +++ b/Gvisual/src/gvisual/TreeAnalyzer.java @@ -35,7 +35,7 @@ */ public class TreeAnalyzer { - private final Graph graph; + private final Graph graph; /** * Create a new tree analyzer for the given graph. @@ -43,7 +43,7 @@ public class TreeAnalyzer { * @param graph the JUNG graph to analyze (should be undirected) * @throws IllegalArgumentException if graph is null */ - public TreeAnalyzer(Graph graph) { + public TreeAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } diff --git a/Gvisual/src/gvisual/TreewidthAnalyzer.java b/Gvisual/src/gvisual/TreewidthAnalyzer.java index 0335c4f..5110318 100644 --- a/Gvisual/src/gvisual/TreewidthAnalyzer.java +++ b/Gvisual/src/gvisual/TreewidthAnalyzer.java @@ -28,7 +28,7 @@ */ public class TreewidthAnalyzer { - private final Graph graph; + private final Graph graph; /** * A bag in a tree decomposition. @@ -114,7 +114,7 @@ public TreewidthReport() { } } - public TreewidthAnalyzer(Graph graph) { + public TreewidthAnalyzer(Graph graph) { if (graph == null) throw new IllegalArgumentException("Graph cannot be null"); this.graph = graph; } @@ -686,7 +686,7 @@ public boolean validateDecomposition(TreeDecomposition td) { } // Check every edge is covered by some bag - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { Collection endpoints = graph.getEndpoints(e); List epList = new ArrayList<>(endpoints); if (epList.size() != 2) continue; diff --git a/Gvisual/src/gvisual/VertexConnectivityAnalyzer.java b/Gvisual/src/gvisual/VertexConnectivityAnalyzer.java index 3d24e3c..dbb30a2 100644 --- a/Gvisual/src/gvisual/VertexConnectivityAnalyzer.java +++ b/Gvisual/src/gvisual/VertexConnectivityAnalyzer.java @@ -43,10 +43,10 @@ */ public class VertexConnectivityAnalyzer { - private final Graph graph; + private final Graph graph; private static final int ALL_CUTS_LIMIT = 20; - public VertexConnectivityAnalyzer(Graph graph) { + public VertexConnectivityAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -60,7 +60,7 @@ public static class ConnectivityResult { private final int edgeConnectivity; private final int minDegree; private final Set minimumVertexCut; - private final Set minimumEdgeCut; + private final Set minimumEdgeCut; private final boolean whitneyHolds; private final int vertexCount; private final int edgeCount; @@ -68,7 +68,7 @@ public static class ConnectivityResult { public ConnectivityResult(int vertexConnectivity, int edgeConnectivity, int minDegree, Set minimumVertexCut, - Set minimumEdgeCut, boolean whitneyHolds, + Set minimumEdgeCut, boolean whitneyHolds, int vertexCount, int edgeCount, boolean isConnected) { this.vertexConnectivity = vertexConnectivity; this.edgeConnectivity = edgeConnectivity; @@ -85,7 +85,7 @@ public ConnectivityResult(int vertexConnectivity, int edgeConnectivity, public int getEdgeConnectivity() { return edgeConnectivity; } public int getMinDegree() { return minDegree; } public Set getMinimumVertexCut() { return minimumVertexCut; } - public Set getMinimumEdgeCut() { return minimumEdgeCut; } + public Set getMinimumEdgeCut() { return minimumEdgeCut; } public boolean isWhitneyHolds() { return whitneyHolds; } public int getVertexCount() { return vertexCount; } public int getEdgeCount() { return edgeCount; } @@ -98,13 +98,13 @@ public static class PairwiseResult { private final int vertexConnectivity; private final int edgeConnectivity; private final Set minimumVertexCut; - private final Set minimumEdgeCut; + private final Set minimumEdgeCut; private final List> vertexDisjointPaths; private final List> edgeDisjointPaths; public PairwiseResult(String source, String target, int vertexConnectivity, int edgeConnectivity, - Set minimumVertexCut, Set minimumEdgeCut, + Set minimumVertexCut, Set minimumEdgeCut, List> vertexDisjointPaths, List> edgeDisjointPaths) { this.source = source; @@ -122,7 +122,7 @@ public PairwiseResult(String source, String target, public int getVertexConnectivity() { return vertexConnectivity; } public int getEdgeConnectivity() { return edgeConnectivity; } public Set getMinimumVertexCut() { return minimumVertexCut; } - public Set getMinimumEdgeCut() { return minimumEdgeCut; } + public Set getMinimumEdgeCut() { return minimumEdgeCut; } public List> getVertexDisjointPaths() { return vertexDisjointPaths; } public List> getEdgeDisjointPaths() { return edgeDisjointPaths; } } @@ -246,7 +246,7 @@ public Set minimumVertexCut() { /** * Find a minimum edge cut set. */ - public Set minimumEdgeCut() { + public Set minimumEdgeCut() { int n = graph.getVertexCount(); if (n <= 1 || !isConnected()) return Collections.emptySet(); @@ -297,7 +297,7 @@ public PairwiseResult pairwiseConnectivity(String s, String t) { int vc = maxFlowVertexSplit(s, t); Set vCut = extractVertexCut(s, t); int ec = maxFlowEdge(s, t); - Set eCut = extractEdgeCut(s, t); + Set eCut = extractEdgeCut(s, t); List> vPaths = findVertexDisjointPaths(s, t); List> ePaths = findEdgeDisjointPaths(s, t); @@ -356,7 +356,7 @@ public Map vertexCriticality() { Map criticality = new LinkedHashMap<>(); for (String v : graph.getVertices()) { - Graph reduced = removeVertex(v); + Graph reduced = removeVertex(v); VertexConnectivityAnalyzer sub = new VertexConnectivityAnalyzer(reduced); int subKappa; if (reduced.getVertexCount() <= 1) { @@ -379,7 +379,7 @@ public ConnectivityResult analyze() { int lambda = edgeConnectivity(); int delta = minDegree(); Set vCut = minimumVertexCut(); - Set eCut = minimumEdgeCut(); + Set eCut = minimumEdgeCut(); boolean whitney = kappa <= lambda && lambda <= delta; return new ConnectivityResult(kappa, lambda, delta, vCut, eCut, @@ -438,10 +438,10 @@ public String generateReport() { sb.append(String.format(" Size: %d\n\n", vCut.size())); } - Set eCut = minimumEdgeCut(); + Set eCut = minimumEdgeCut(); if (!eCut.isEmpty()) { sb.append("Minimum edge cut:\n"); - for (edge e : eCut) { + for (Edge e : eCut) { sb.append(String.format(" %s\n", e)); } sb.append(String.format(" Size: %d\n\n", eCut.size())); @@ -489,7 +489,7 @@ private Map> buildVertexSplitNetwork(String s, Stri } } - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { Collection endpoints = graph.getEndpoints(e); Iterator it = endpoints.iterator(); String u = it.next(); @@ -507,7 +507,7 @@ private int maxFlowEdge(String s, String t) { cap.putIfAbsent(v, new HashMap<>()); } - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { Collection endpoints = graph.getEndpoints(e); Iterator it = endpoints.iterator(); String u = it.next(); @@ -635,12 +635,12 @@ private Set extractVertexCut(String s, String t) { return cut; } - private Set extractEdgeCut(String s, String t) { + private Set extractEdgeCut(String s, String t) { Map> cap = new HashMap<>(); for (String v : graph.getVertices()) { cap.putIfAbsent(v, new HashMap<>()); } - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { Collection endpoints = graph.getEndpoints(e); Iterator it = endpoints.iterator(); String u = it.next(); @@ -694,8 +694,8 @@ private Set extractEdgeCut(String s, String t) { } } - Set cutEdges = new LinkedHashSet<>(); - for (edge e : graph.getEdges()) { + Set cutEdges = new LinkedHashSet<>(); + for (Edge e : graph.getEdges()) { Collection endpoints = graph.getEndpoints(e); Iterator it = endpoints.iterator(); String u = it.next(); @@ -779,7 +779,7 @@ public List> findEdgeDisjointPaths(String s, String t) { for (String v : graph.getVertices()) { cap.putIfAbsent(v, new HashMap<>()); } - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { Collection endpoints = graph.getEndpoints(e); Iterator it = endpoints.iterator(); String u = it.next(); @@ -844,18 +844,18 @@ private void addCapacity(Map> cap, String from, Str cap.get(from).merge(to, c, Integer::sum); } - private Graph removeVertex(String toRemove) { - Graph g = new UndirectedSparseGraph<>(); + private Graph removeVertex(String toRemove) { + Graph g = new UndirectedSparseGraph<>(); for (String v : graph.getVertices()) { if (!v.equals(toRemove)) g.addVertex(v); } - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { Collection endpoints = graph.getEndpoints(e); Iterator it = endpoints.iterator(); String u = it.next(); String v = it.next(); if (!u.equals(toRemove) && !v.equals(toRemove)) { - g.addEdge(new edge("f", u, v), u, v); + g.addEdge(new Edge("f", u, v), u, v); } } return g; diff --git a/Gvisual/src/gvisual/VertexCoverAnalyzer.java b/Gvisual/src/gvisual/VertexCoverAnalyzer.java index b888680..f496628 100644 --- a/Gvisual/src/gvisual/VertexCoverAnalyzer.java +++ b/Gvisual/src/gvisual/VertexCoverAnalyzer.java @@ -41,7 +41,7 @@ */ public class VertexCoverAnalyzer { - private final Graph graph; + private final Graph graph; private final Map> adj; /** @@ -50,7 +50,7 @@ public class VertexCoverAnalyzer { * @param graph the JUNG graph to analyse * @throws IllegalArgumentException if graph is null */ - public VertexCoverAnalyzer(Graph graph) { + public VertexCoverAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -71,7 +71,7 @@ public Set approxVertexCover() { Set cover = new LinkedHashSet(); Set coveredEdgeKeys = new HashSet(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); String key = edgeKey(v1, v2); @@ -231,7 +231,7 @@ public boolean isVertexCover(Set cover) { if (cover == null) { throw new IllegalArgumentException("Cover set must not be null"); } - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { if (!cover.contains(e.getVertex1()) && !cover.contains(e.getVertex2())) { return false; } @@ -253,7 +253,7 @@ public List uncoveredEdges(Set cover) { throw new IllegalArgumentException("Cover set must not be null"); } List uncovered = new ArrayList(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { if (!cover.contains(e.getVertex1()) && !cover.contains(e.getVertex2())) { uncovered.add(new String[]{e.getVertex1(), e.getVertex2()}); } @@ -325,7 +325,7 @@ public CoverBounds coverBounds() { private int greedyMaxMatchingSize() { Set matched = new HashSet(); int count = 0; - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); if (!matched.contains(v1) && !matched.contains(v2)) { @@ -424,7 +424,7 @@ public int lpRelaxationBound() { // In the LP relaxation of vertex cover, the optimal fractional // solution assigns 0.5 to every vertex incident to any edge. Set incidentVertices = new HashSet(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { incidentVertices.add(e.getVertex1()); incidentVertices.add(e.getVertex2()); } diff --git a/Gvisual/src/test/GraphTimelineExporterTest.java b/Gvisual/src/test/GraphTimelineExporterTest.java index 7cb8e04..3e9b871 100644 --- a/Gvisual/src/test/GraphTimelineExporterTest.java +++ b/Gvisual/src/test/GraphTimelineExporterTest.java @@ -18,20 +18,20 @@ public class GraphTimelineExporterTest { @Before public void setUp() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setTimestamp(1000L); g.addEdge(e1, "A", "B"); - edge e2 = new edge("c", "B", "C"); + edge e2 = new Edge("c", "B", "C"); e2.setTimestamp(2000L); g.addEdge(e2, "B", "C"); - edge e3 = new edge("s", "A", "C"); + edge e3 = new Edge("s", "A", "C"); e3.setTimestamp(3000L); g.addEdge(e3, "A", "C"); diff --git a/Gvisual/src/test/gvisual/CycleAnalyzerTest.java b/Gvisual/src/test/gvisual/CycleAnalyzerTest.java index 03b8729..5145cc2 100644 --- a/Gvisual/src/test/gvisual/CycleAnalyzerTest.java +++ b/Gvisual/src/test/gvisual/CycleAnalyzerTest.java @@ -19,18 +19,18 @@ public class CycleAnalyzerTest { private static int edgeCounter = 0; - private static edge addEdge(Graph g, String v1, String v2) { + private static edge addEdge(Graph g, String v1, String v2) { g.addVertex(v1); g.addVertex(v2); - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); g.addEdge(e, v1, v2); return e; } - private static edge addWeightedEdge(Graph g, String v1, String v2, float w) { + private static edge addWeightedEdge(Graph g, String v1, String v2, float w) { g.addVertex(v1); g.addVertex(v2); - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(w); g.addEdge(e, v1, v2); return e; @@ -47,14 +47,14 @@ public void testNullGraphThrows() { @Test public void testEmptyGraphHasNoCycles() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); CycleAnalyzer ca = new CycleAnalyzer(g); assertFalse(ca.hasCycles()); } @Test public void testSingleVertexNoCycle() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); assertFalse(new CycleAnalyzer(g).hasCycles()); } @@ -62,7 +62,7 @@ public void testSingleVertexNoCycle() { @Test public void testTreeNoCycleUndirected() { // A-B-C (path, no cycle) - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); assertFalse(new CycleAnalyzer(g).hasCycles()); @@ -70,7 +70,7 @@ public void testTreeNoCycleUndirected() { @Test public void testTriangleCycleUndirected() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -79,7 +79,7 @@ public void testTriangleCycleUndirected() { @Test public void testSquareCycleUndirected() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -91,7 +91,7 @@ public void testSquareCycleUndirected() { @Test public void testDAGNoCycle() { - Graph g = new DirectedSparseGraph<>(); + Graph g = new DirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "A", "C"); @@ -100,7 +100,7 @@ public void testDAGNoCycle() { @Test public void testDirectedTriangleCycle() { - Graph g = new DirectedSparseGraph<>(); + Graph g = new DirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -109,7 +109,7 @@ public void testDirectedTriangleCycle() { @Test public void testSelfLoopDirected() { - Graph g = new DirectedSparseGraph<>(); + Graph g = new DirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "A"); assertTrue(new CycleAnalyzer(g).hasCycles()); @@ -119,13 +119,13 @@ public void testSelfLoopDirected() { @Test public void testGirthEmptyGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); assertEquals(-1, new CycleAnalyzer(g).girth()); } @Test public void testGirthAcyclic() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); assertEquals(-1, new CycleAnalyzer(g).girth()); @@ -133,7 +133,7 @@ public void testGirthAcyclic() { @Test public void testGirthTriangle() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -143,7 +143,7 @@ public void testGirthTriangle() { @Test public void testGirthSquareWithDiagonal() { // Square A-B-C-D-A plus diagonal A-C → shortest cycle is triangle - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -154,7 +154,7 @@ public void testGirthSquareWithDiagonal() { @Test public void testGirthDirectedCycle() { - Graph g = new DirectedSparseGraph<>(); + Graph g = new DirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -165,14 +165,14 @@ public void testGirthDirectedCycle() { @Test public void testFundamentalBasisEmpty() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); List basis = new CycleAnalyzer(g).fundamentalCycleBasis(); assertTrue(basis.isEmpty()); } @Test public void testFundamentalBasisTree() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -183,7 +183,7 @@ public void testFundamentalBasisTree() { @Test public void testFundamentalBasisSingleCycle() { // Triangle: 1 non-tree edge → 1 fundamental cycle - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -195,7 +195,7 @@ public void testFundamentalBasisSingleCycle() { @Test public void testFundamentalBasisK4() { // K4: 4 vertices, 6 edges → cyclomatic number = 6 - 4 + 1 = 3 - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); String[] verts = {"A", "B", "C", "D"}; for (int i = 0; i < verts.length; i++) { for (int j = i + 1; j < verts.length; j++) { @@ -210,7 +210,7 @@ public void testFundamentalBasisK4() { @Test public void testEnumerateNoCycles() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); CycleAnalyzer.CycleEnumerationResult r = new CycleAnalyzer(g).findAllSimpleCycles(); assertEquals(0, r.count()); @@ -219,7 +219,7 @@ public void testEnumerateNoCycles() { @Test public void testEnumerateTriangle() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -231,7 +231,7 @@ public void testEnumerateTriangle() { @Test public void testEnumerateWithLimit() { // K4 has 7 cycles — set limit to 2 - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); String[] verts = {"A", "B", "C", "D"}; for (int i = 0; i < verts.length; i++) { for (int j = i + 1; j < verts.length; j++) { @@ -245,14 +245,14 @@ public void testEnumerateWithLimit() { @Test(expected = IllegalArgumentException.class) public void testEnumerateNegativeLimit() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); new CycleAnalyzer(g).findAllSimpleCycles(-1); } @Test public void testEnumerateDirectedCycles() { // A→B→C→A and A→B→D→A - Graph g = new DirectedSparseGraph<>(); + Graph g = new DirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -289,7 +289,7 @@ public void testCycleDifferentVerticesNotEqual() { @Test public void testCycleWeight() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addWeightedEdge(g, "A", "B", 1.5f); addWeightedEdge(g, "B", "C", 2.5f); addWeightedEdge(g, "C", "A", 3.0f); @@ -307,7 +307,7 @@ public void testCycleToString() { @Test public void testAnalyzeAcyclicGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); CycleAnalyzer.CycleReport report = new CycleAnalyzer(g).analyze(); @@ -323,7 +323,7 @@ public void testAnalyzeAcyclicGraph() { @Test public void testAnalyzeTriangle() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -343,7 +343,7 @@ public void testAnalyzeTriangle() { @Test public void testAnalyzeK4() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); String[] verts = {"A", "B", "C", "D"}; for (int i = 0; i < verts.length; i++) { for (int j = i + 1; j < verts.length; j++) { @@ -364,7 +364,7 @@ public void testAnalyzeK4() { @Test public void testAnalyzeReportSummaryAcyclic() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); CycleAnalyzer.CycleReport report = new CycleAnalyzer(g).analyze(); assertTrue(report.getSummary().contains("No cycles found")); @@ -374,7 +374,7 @@ public void testAnalyzeReportSummaryAcyclic() { @Test public void testDisconnectedGraphWithOneCyclicComponent() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); // Component 1: triangle addEdge(g, "A", "B"); addEdge(g, "B", "C"); @@ -388,7 +388,7 @@ public void testDisconnectedGraphWithOneCyclicComponent() { @Test public void testDisconnectedAcyclic() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, "A", "B"); addEdge(g, "X", "Y"); assertFalse(new CycleAnalyzer(g).hasCycles()); diff --git a/Gvisual/src/test/gvisual/GraphCompressorTest.java b/Gvisual/src/test/gvisual/GraphCompressorTest.java index 4f23ed7..068a60b 100644 --- a/Gvisual/src/test/gvisual/GraphCompressorTest.java +++ b/Gvisual/src/test/gvisual/GraphCompressorTest.java @@ -14,7 +14,7 @@ */ public class GraphCompressorTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -510,7 +510,7 @@ public void testEdgeReductionPercent_noEdges() { // ── Helper ────────────────────────────────────────────────────── private void addEdge(String v1, String v2, String id) { - edge e = new edge("test", v1, v2); + edge e = new Edge("test", v1, v2); e.setLabel(id); graph.addEdge(e, v1, v2); } diff --git a/Gvisual/src/test/gvisual/GraphMergerTest.java b/Gvisual/src/test/gvisual/GraphMergerTest.java index bf92c31..24140d5 100644 --- a/Gvisual/src/test/gvisual/GraphMergerTest.java +++ b/Gvisual/src/test/gvisual/GraphMergerTest.java @@ -12,8 +12,8 @@ */ public class GraphMergerTest { - private Graph graphA; - private Graph graphB; + private Graph graphA; + private Graph graphB; @Before public void setUp() { @@ -22,7 +22,7 @@ public void setUp() { } private edge makeEdge(String v1, String v2, float weight) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(weight); return e; } diff --git a/Gvisual/src/test/gvisual/GraphProductCalculatorTest.java b/Gvisual/src/test/gvisual/GraphProductCalculatorTest.java index 88edcc0..9669f1f 100644 --- a/Gvisual/src/test/gvisual/GraphProductCalculatorTest.java +++ b/Gvisual/src/test/gvisual/GraphProductCalculatorTest.java @@ -15,41 +15,41 @@ */ public class GraphProductCalculatorTest { - private Graph triangle; // K3: 3 vertices, 3 edges - private Graph path2; // P2: 2 vertices, 1 edge - private Graph single; // K1: 1 vertex, 0 edges - private Graph k2; // K2: 2 vertices, 1 edge - private Graph empty3; // 3 isolated vertices + private Graph triangle; // K3: 3 vertices, 3 edges + private Graph path2; // P2: 2 vertices, 1 edge + private Graph single; // K1: 1 vertex, 0 edges + private Graph k2; // K2: 2 vertices, 1 edge + private Graph empty3; // 3 isolated vertices @Before public void setUp() { // Triangle K3: a-b, b-c, a-c - triangle = new UndirectedSparseGraph(); + triangle = new UndirectedSparseGraph(); triangle.addVertex("a"); triangle.addVertex("b"); triangle.addVertex("c"); - triangle.addEdge(new edge("e", "a", "b"), "a", "b"); - triangle.addEdge(new edge("e", "b", "c"), "b", "c"); - triangle.addEdge(new edge("e", "a", "c"), "a", "c"); + triangle.addEdge(new Edge("e", "a", "b"), "a", "b"); + triangle.addEdge(new Edge("e", "b", "c"), "b", "c"); + triangle.addEdge(new Edge("e", "a", "c"), "a", "c"); // Path P2: x-y - path2 = new UndirectedSparseGraph(); + path2 = new UndirectedSparseGraph(); path2.addVertex("x"); path2.addVertex("y"); - path2.addEdge(new edge("e", "x", "y"), "x", "y"); + path2.addEdge(new Edge("e", "x", "y"), "x", "y"); // Single vertex - single = new UndirectedSparseGraph(); + single = new UndirectedSparseGraph(); single.addVertex("s"); // K2: p-q - k2 = new UndirectedSparseGraph(); + k2 = new UndirectedSparseGraph(); k2.addVertex("p"); k2.addVertex("q"); - k2.addEdge(new edge("e", "p", "q"), "p", "q"); + k2.addEdge(new Edge("e", "p", "q"), "p", "q"); // Empty graph with 3 vertices - empty3 = new UndirectedSparseGraph(); + empty3 = new UndirectedSparseGraph(); empty3.addVertex("1"); empty3.addVertex("2"); empty3.addVertex("3"); @@ -70,7 +70,7 @@ public void testNullGraphH() { @Test public void testCartesianVertexCount() { GraphProductCalculator calc = new GraphProductCalculator(triangle, path2); - Graph result = calc.cartesianProduct(); + Graph result = calc.cartesianProduct(); assertEquals(6, result.getVertexCount()); // 3 * 2 } @@ -236,8 +236,8 @@ public void testDegreeSequence() { @Test public void testCachingReturnsSameInstance() { GraphProductCalculator calc = new GraphProductCalculator(triangle, path2); - Graph first = calc.cartesianProduct(); - Graph second = calc.cartesianProduct(); + Graph first = calc.cartesianProduct(); + Graph second = calc.cartesianProduct(); assertSame(first, second); } @@ -246,7 +246,7 @@ public void testCachingReturnsSameInstance() { @Test public void testVertexNaming() { GraphProductCalculator calc = new GraphProductCalculator(k2, k2); - Graph product = calc.cartesianProduct(); + Graph product = calc.cartesianProduct(); assertTrue(product.containsVertex("(p,p)")); assertTrue(product.containsVertex("(p,q)")); assertTrue(product.containsVertex("(q,p)")); @@ -258,7 +258,7 @@ public void testVertexNaming() { @Test public void testCartesianWithEmptyGraph() { GraphProductCalculator calc = new GraphProductCalculator(triangle, empty3); - Graph result = calc.cartesianProduct(); + Graph result = calc.cartesianProduct(); assertEquals(9, result.getVertexCount()); // |E_G|*|V_H| + |V_G|*|E_H| = 3*3 + 3*0 = 9 assertEquals(9, result.getEdgeCount()); diff --git a/Gvisual/src/test/gvisual/PageRankAnalyzerTest.java b/Gvisual/src/test/gvisual/PageRankAnalyzerTest.java index 6194a0d..d3b7d4d 100644 --- a/Gvisual/src/test/gvisual/PageRankAnalyzerTest.java +++ b/Gvisual/src/test/gvisual/PageRankAnalyzerTest.java @@ -15,7 +15,7 @@ public class PageRankAnalyzerTest { private static final double EPSILON = 1e-4; - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -77,7 +77,7 @@ public void testCompleteGraphUniformRanks() { // In a complete graph, all nodes should have equal PageRank GraphGenerator gen = new GraphGenerator(42); GraphGenerator.GeneratedGraph gg = gen.complete(5); - Graph g = gg.getGraph(); + Graph g = gg.getGraph(); PageRankAnalyzer pr = new PageRankAnalyzer(g); pr.compute(); @@ -94,7 +94,7 @@ public void testCompleteGraphUniformRanks() { public void testRingGraphUniformRanks() { GraphGenerator gen = new GraphGenerator(42); GraphGenerator.GeneratedGraph gg = gen.ring(6); - Graph g = gg.getGraph(); + Graph g = gg.getGraph(); PageRankAnalyzer pr = new PageRankAnalyzer(g); pr.compute(); @@ -111,7 +111,7 @@ public void testRingGraphUniformRanks() { public void testStarGraphHubHighestRank() { GraphGenerator gen = new GraphGenerator(42); GraphGenerator.GeneratedGraph gg = gen.star(6); - Graph g = gg.getGraph(); + Graph g = gg.getGraph(); PageRankAnalyzer pr = new PageRankAnalyzer(g); pr.compute(); @@ -130,7 +130,7 @@ public void testStarGraphHubHighestRank() { public void testRanksSumToOne() { GraphGenerator gen = new GraphGenerator(42); GraphGenerator.GeneratedGraph gg = gen.scaleFreeBa(20, 2); - Graph g = gg.getGraph(); + Graph g = gg.getGraph(); PageRankAnalyzer pr = new PageRankAnalyzer(g); pr.compute(); @@ -228,7 +228,7 @@ public void testGetSortedResults() { public void testGetTopK() { GraphGenerator gen = new GraphGenerator(42); GraphGenerator.GeneratedGraph gg = gen.scaleFreeBa(20, 2); - Graph g = gg.getGraph(); + Graph g = gg.getGraph(); PageRankAnalyzer pr = new PageRankAnalyzer(g); pr.compute(); @@ -323,7 +323,7 @@ public void testDanglingNodesGetRank() { private void addEdge(String v1, String v2) { graph.addVertex(v1); graph.addVertex(v2); - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setLabel("e" + (edgeId++)); e.setWeight(1.0f); graph.addEdge(e, v1, v2); diff --git a/Gvisual/test/gvisual/ArticulationPointAnalyzerTest.java b/Gvisual/test/gvisual/ArticulationPointAnalyzerTest.java index 7609eab..6069d86 100644 --- a/Gvisual/test/gvisual/ArticulationPointAnalyzerTest.java +++ b/Gvisual/test/gvisual/ArticulationPointAnalyzerTest.java @@ -14,15 +14,15 @@ */ public class ArticulationPointAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } private edge addEdge(String v1, String v2, String type) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setLabel(v1 + "-" + v2); graph.addEdge(e, v1, v2); return e; diff --git a/Gvisual/test/gvisual/BipartiteAnalyzerTest.java b/Gvisual/test/gvisual/BipartiteAnalyzerTest.java index a2c3136..4f5f16d 100644 --- a/Gvisual/test/gvisual/BipartiteAnalyzerTest.java +++ b/Gvisual/test/gvisual/BipartiteAnalyzerTest.java @@ -15,15 +15,15 @@ */ public class BipartiteAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); @@ -393,7 +393,7 @@ public void vertexCoverCoversAllEdges() { List cover = ba.getMinimumVertexCover(); java.util.Set coverSet = new java.util.HashSet(cover); // Every edge must have at least one endpoint in the cover - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { assertTrue("Edge not covered: " + e.getVertex1() + "-" + e.getVertex2(), coverSet.contains(e.getVertex1()) || coverSet.contains(e.getVertex2())); } @@ -430,7 +430,7 @@ public void coloringIsValid() { addEdge("C", "D"); BipartiteAnalyzer ba = new BipartiteAnalyzer(graph).compute(); Map coloring = ba.getColoring(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); assertNotEquals("Adjacent vertices have same color: " + v1 + "-" + v2, diff --git a/Gvisual/test/gvisual/ChordalGraphAnalyzerTest.java b/Gvisual/test/gvisual/ChordalGraphAnalyzerTest.java index 9b20a57..5ff693f 100644 --- a/Gvisual/test/gvisual/ChordalGraphAnalyzerTest.java +++ b/Gvisual/test/gvisual/ChordalGraphAnalyzerTest.java @@ -14,17 +14,17 @@ */ public class ChordalGraphAnalyzerTest { - private Graph emptyGraph; - private Graph singleVertex; - private Graph singleEdge; - private Graph triangle; // K3 — chordal - private Graph path4; // A-B-C-D — chordal - private Graph cycle4; // A-B-C-D-A — NOT chordal - private Graph cycle5; // 5-cycle — NOT chordal - private Graph complete4; // K4 — chordal - private Graph diamond; // K4 minus one edge — chordal - private Graph star5; // star — chordal - private Graph fan; // fan graph — chordal + private Graph emptyGraph; + private Graph singleVertex; + private Graph singleEdge; + private Graph triangle; // K3 — chordal + private Graph path4; // A-B-C-D — chordal + private Graph cycle4; // A-B-C-D-A — NOT chordal + private Graph cycle5; // 5-cycle — NOT chordal + private Graph complete4; // K4 — chordal + private Graph diamond; // K4 minus one edge — chordal + private Graph star5; // star — chordal + private Graph fan; // fan graph — chordal private int edgeCounter; @@ -97,10 +97,10 @@ public void setUp() { addEdge(fan, "X", "D"); } - private void addEdge(Graph g, String u, String v) { + private void addEdge(Graph g, String u, String v) { if (!g.containsVertex(u)) g.addVertex(u); if (!g.containsVertex(v)) g.addVertex(v); - g.addEdge(new edge("e" + (++edgeCounter), u, v), u, v); + g.addEdge(new Edge("e" + (++edgeCounter), u, v), u, v); } // ── MCS ordering ──────────────────────────────────────────────────── @@ -247,7 +247,7 @@ public void testColoringStar() { public void testColoringIsValid() { ChordalGraphAnalyzer.ColoringResult c = ChordalGraphAnalyzer.optimalColoring(fan); Map colors = c.getColors(); - for (edge e : fan.getEdges()) { + for (Edge e : fan.getEdges()) { assertNotEquals("Adjacent vertices must have different colors: " + e.getVertex1() + "-" + e.getVertex2(), colors.get(e.getVertex1()), colors.get(e.getVertex2())); } diff --git a/Gvisual/test/gvisual/CircularLayoutTest.java b/Gvisual/test/gvisual/CircularLayoutTest.java index ce07ab8..270027e 100644 --- a/Gvisual/test/gvisual/CircularLayoutTest.java +++ b/Gvisual/test/gvisual/CircularLayoutTest.java @@ -14,9 +14,9 @@ */ public class CircularLayoutTest { - private Graph triangle; - private Graph star; - private Graph empty; + private Graph triangle; + private Graph star; + private Graph empty; @Before public void setUp() { @@ -42,7 +42,7 @@ public void setUp() { } private edge makeEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); e.setLabel(v1 + "-" + v2); return e; @@ -104,7 +104,7 @@ public void testBfsOrdering() { @Test public void testCommunityOrdering() { // Two disconnected components - Graph disconnected = new UndirectedSparseGraph<>(); + Graph disconnected = new UndirectedSparseGraph<>(); disconnected.addVertex("A1"); disconnected.addVertex("A2"); disconnected.addEdge(makeEdge("A1", "A2"), "A1", "A2"); @@ -202,7 +202,7 @@ public void testSvgExport() { @Test public void testSvgHidesLabelsForLargeGraphs() { // Create graph with 100 nodes - Graph large = new UndirectedSparseGraph<>(); + Graph large = new UndirectedSparseGraph<>(); for (int i = 0; i < 100; i++) { large.addVertex("n" + i); } @@ -232,7 +232,7 @@ public void testNullGraph() { @Test public void testSingleNode() { - Graph single = new UndirectedSparseGraph<>(); + Graph single = new UndirectedSparseGraph<>(); single.addVertex("alone"); CircularLayout layout = new CircularLayout.Builder(single) .ordering(CircularLayout.Ordering.ALPHABETICAL) diff --git a/Gvisual/test/gvisual/CliqueAnalyzerTest.java b/Gvisual/test/gvisual/CliqueAnalyzerTest.java index edee4e3..6ec6e6f 100644 --- a/Gvisual/test/gvisual/CliqueAnalyzerTest.java +++ b/Gvisual/test/gvisual/CliqueAnalyzerTest.java @@ -14,17 +14,17 @@ */ public class CliqueAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // --- Helpers --- private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/CommunityDetectorTest.java b/Gvisual/test/gvisual/CommunityDetectorTest.java index 63a6eda..6a6e98f 100644 --- a/Gvisual/test/gvisual/CommunityDetectorTest.java +++ b/Gvisual/test/gvisual/CommunityDetectorTest.java @@ -14,11 +14,11 @@ */ public class CommunityDetectorTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } @Test(expected = IllegalArgumentException.class) @@ -60,7 +60,7 @@ public void testTwoDisconnectedNodes() { public void testTwoConnectedNodes() { graph.addVertex("A"); graph.addVertex("B"); - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(5.0f); graph.addEdge(e, "A", "B"); @@ -77,9 +77,9 @@ public void testTwoCommunities() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(3.0f); - edge e2 = new edge("f", "B", "C"); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(4.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -87,7 +87,7 @@ public void testTwoCommunities() { // Community 2: D-E graph.addVertex("D"); graph.addVertex("E"); - edge e3 = new edge("c", "D", "E"); + edge e3 = new Edge("c", "D", "E"); e3.setWeight(6.0f); graph.addEdge(e3, "D", "E"); @@ -104,7 +104,7 @@ public void testTwoCommunities() { public void testNodeToCommunityMapping() { graph.addVertex("A"); graph.addVertex("B"); - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); graph.addEdge(e1, "A", "B"); @@ -127,9 +127,9 @@ public void testCommunityDensity() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(1.0f); - edge e3 = new edge("f", "A", "C"); e3.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(1.0f); + edge e3 = new Edge("f", "A", "C"); e3.setWeight(1.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); graph.addEdge(e3, "A", "C"); @@ -152,9 +152,9 @@ public void testEdgeTypeCounts() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("c", "B", "C"); e2.setWeight(2.0f); - edge e3 = new edge("f", "A", "C"); e3.setWeight(3.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("c", "B", "C"); e2.setWeight(2.0f); + edge e3 = new Edge("f", "A", "C"); e3.setWeight(3.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); graph.addEdge(e3, "A", "C"); @@ -173,8 +173,8 @@ public void testAverageWeight() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(10.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(20.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(10.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(20.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -189,14 +189,14 @@ public void testSignificantCommunities() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(1.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); graph.addVertex("D"); graph.addVertex("E"); - edge e3 = new edge("c", "D", "E"); e3.setWeight(1.0f); + edge e3 = new Edge("c", "D", "E"); e3.setWeight(1.0f); graph.addEdge(e3, "D", "E"); graph.addVertex("F"); // isolated @@ -215,7 +215,7 @@ public void testSignificantCommunities() { public void testGetCommunityOf() { graph.addVertex("A"); graph.addVertex("B"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); graph.addEdge(e1, "A", "B"); CommunityDetector detector = new CommunityDetector(graph); @@ -235,9 +235,9 @@ public void testModularity() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(1.0f); - edge e3 = new edge("f", "A", "C"); e3.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(1.0f); + edge e3 = new Edge("f", "A", "C"); e3.setWeight(1.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); graph.addEdge(e3, "A", "C"); @@ -245,9 +245,9 @@ public void testModularity() { graph.addVertex("D"); graph.addVertex("E"); graph.addVertex("F"); - edge e4 = new edge("c", "D", "E"); e4.setWeight(1.0f); - edge e5 = new edge("c", "E", "F"); e5.setWeight(1.0f); - edge e6 = new edge("c", "D", "F"); e6.setWeight(1.0f); + edge e4 = new Edge("c", "D", "E"); e4.setWeight(1.0f); + edge e5 = new Edge("c", "E", "F"); e5.setWeight(1.0f); + edge e6 = new Edge("c", "D", "F"); e6.setWeight(1.0f); graph.addEdge(e4, "D", "E"); graph.addEdge(e5, "E", "F"); graph.addEdge(e6, "D", "F"); @@ -273,7 +273,7 @@ public void testModularitySingleComponent() { // All in one component → modularity should be 0 graph.addVertex("A"); graph.addVertex("B"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); graph.addEdge(e1, "A", "B"); CommunityDetector detector = new CommunityDetector(graph); @@ -287,7 +287,7 @@ public void testModularitySingleComponent() { public void testCommunityToString() { graph.addVertex("A"); graph.addVertex("B"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(5.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(5.0f); graph.addEdge(e1, "A", "B"); CommunityDetector detector = new CommunityDetector(graph); @@ -311,8 +311,8 @@ public void testTotalWeight() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(7.5f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(2.5f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(7.5f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(2.5f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -332,10 +332,10 @@ public void testLargerGraph() { graph.addVertex("F"); graph.addVertex("G"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("c", "A", "C"); e2.setWeight(2.0f); - edge e3 = new edge("s", "A", "D"); e3.setWeight(3.0f); - edge e4 = new edge("sg", "A", "E"); e4.setWeight(4.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("c", "A", "C"); e2.setWeight(2.0f); + edge e3 = new Edge("s", "A", "D"); e3.setWeight(3.0f); + edge e4 = new Edge("sg", "A", "E"); e4.setWeight(4.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "A", "C"); graph.addEdge(e3, "A", "D"); @@ -359,9 +359,9 @@ public void testMultipleEdgeTypes() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("fs", "B", "C"); e2.setWeight(1.0f); - edge e3 = new edge("sg", "A", "C"); e3.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("fs", "B", "C"); e2.setWeight(1.0f); + edge e3 = new Edge("sg", "A", "C"); e3.setWeight(1.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); graph.addEdge(e3, "A", "C"); @@ -400,14 +400,14 @@ public void testGetCommunityOfValidNodeAfterDetect() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(1.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); graph.addVertex("D"); graph.addVertex("E"); - edge e3 = new edge("c", "D", "E"); e3.setWeight(1.0f); + edge e3 = new Edge("c", "D", "E"); e3.setWeight(1.0f); graph.addEdge(e3, "D", "E"); CommunityDetector detector = new CommunityDetector(graph); @@ -436,7 +436,7 @@ public void testGetCommunityOfConsistentWithDirectIndex() { // Verify getCommunityOf returns same object as communities.get(id) graph.addVertex("A"); graph.addVertex("B"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); graph.addEdge(e1, "A", "B"); graph.addVertex("C"); // isolated @@ -457,7 +457,7 @@ public void testDetectInPlaceIdReassignment() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); graph.addEdge(e1, "A", "B"); // C is isolated → two communities diff --git a/Gvisual/test/gvisual/CommunityEvolutionTrackerTest.java b/Gvisual/test/gvisual/CommunityEvolutionTrackerTest.java index 2505eb2..cbfcb95 100644 --- a/Gvisual/test/gvisual/CommunityEvolutionTrackerTest.java +++ b/Gvisual/test/gvisual/CommunityEvolutionTrackerTest.java @@ -19,19 +19,19 @@ public class CommunityEvolutionTrackerTest { // ── Helper Methods ───────────────────────────────────────────── private edge timedEdge(String type, String v1, String v2, long timestamp) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setTimestamp(timestamp); return e; } private edge intervalEdge(String type, String v1, String v2, long start, long end) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setTimestamp(start); e.setEndTimestamp(end); return e; } - private void addEdge(Graph graph, edge e) { + private void addEdge(Graph graph, edge e) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); if (!graph.containsVertex(v1)) graph.addVertex(v1); @@ -57,7 +57,7 @@ public void constructor_nullGraph_throws() { @Test(expected = IllegalArgumentException.class) public void track_singleWindow_throws() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); tracker.track(1); @@ -65,7 +65,7 @@ public void track_singleWindow_throws() { @Test(expected = IllegalArgumentException.class) public void trackAtTimePoints_nullList_throws() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); tracker.trackAtTimePoints(null); @@ -73,7 +73,7 @@ public void trackAtTimePoints_nullList_throws() { @Test(expected = IllegalArgumentException.class) public void trackAtTimePoints_singlePoint_throws() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); tracker.trackAtTimePoints(Collections.singletonList(100L)); @@ -83,7 +83,7 @@ public void trackAtTimePoints_singlePoint_throws() { @Test(expected = IllegalArgumentException.class) public void setMatchThreshold_negative_throws() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); tracker.setMatchThreshold(-0.1); @@ -91,7 +91,7 @@ public void setMatchThreshold_negative_throws() { @Test(expected = IllegalArgumentException.class) public void setMatchThreshold_overOne_throws() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); tracker.setMatchThreshold(1.1); @@ -99,7 +99,7 @@ public void setMatchThreshold_overOne_throws() { @Test(expected = IllegalArgumentException.class) public void setChangeThreshold_negative_throws() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); tracker.setChangeThreshold(-0.1); @@ -107,7 +107,7 @@ public void setChangeThreshold_negative_throws() { @Test(expected = IllegalArgumentException.class) public void setChangeThreshold_overOne_throws() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); tracker.setChangeThreshold(1.1); @@ -115,7 +115,7 @@ public void setChangeThreshold_overOne_throws() { @Test(expected = IllegalArgumentException.class) public void setMinCommunitySize_zero_throws() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); tracker.setMinCommunitySize(0); @@ -123,7 +123,7 @@ public void setMinCommunitySize_zero_throws() { @Test public void gettersReturnDefaults() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); assertEquals(0.3, tracker.getMatchThreshold(), 0.001); @@ -135,7 +135,7 @@ public void gettersReturnDefaults() { @Test public void stableCommunity_sameGroupAcrossTime() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); addEdge(g, intervalEdge("f", "A", "C", 100, 200)); @@ -154,7 +154,7 @@ public void stableCommunity_sameGroupAcrossTime() { @Test public void communityBirth_newGroupAppears() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); addEdge(g, timedEdge("f", "X", "Y", 200)); @@ -172,7 +172,7 @@ public void communityBirth_newGroupAppears() { @Test public void communityDeath_groupDisappears() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, timedEdge("f", "A", "B", 100)); addEdge(g, timedEdge("f", "B", "C", 100)); addEdge(g, intervalEdge("f", "X", "Y", 100, 200)); @@ -190,7 +190,7 @@ public void communityDeath_groupDisappears() { @Test public void communityGrowth_membersAdded() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, timedEdge("f", "B", "C", 200)); addEdge(g, timedEdge("f", "C", "D", 200)); @@ -208,7 +208,7 @@ public void communityGrowth_membersAdded() { @Test public void communityContraction_membersLeave() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); // A-B persists, but C, D, E only at t=100 addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, timedEdge("f", "B", "C", 100)); @@ -227,7 +227,7 @@ public void communityContraction_membersLeave() { @Test public void communityMerge_twoBecomesOne() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); // Two separate communities persist, bridge appears at t=200 addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); @@ -248,7 +248,7 @@ public void communityMerge_twoBecomesOne() { @Test public void communitySplit_oneBecomesTwo() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); // All connected at t=100 via persistent edges + bridge addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); @@ -303,7 +303,7 @@ public void jaccard_oneEmpty() { @Test public void nodeLineage_tracksNodeAcrossSnapshots() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 300)); addEdge(g, intervalEdge("f", "B", "C", 100, 300)); @@ -322,7 +322,7 @@ public void nodeLineage_tracksNodeAcrossSnapshots() { @Test public void nodeLineage_missingNode_emptyList() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); @@ -338,7 +338,7 @@ public void nodeLineage_missingNode_emptyList() { @Test public void stabilityScore_inRange() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); @@ -352,7 +352,7 @@ public void stabilityScore_inRange() { @Test public void volatilityScore_inRange() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, timedEdge("f", "A", "B", 100)); addEdge(g, timedEdge("f", "B", "C", 100)); addEdge(g, timedEdge("f", "X", "Y", 200)); @@ -370,7 +370,7 @@ public void volatilityScore_inRange() { @Test public void getEventsByType_filtersCorrectly() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, timedEdge("f", "A", "B", 100)); addEdge(g, timedEdge("f", "B", "C", 100)); addEdge(g, timedEdge("f", "X", "Y", 200)); @@ -391,7 +391,7 @@ public void getEventsByType_filtersCorrectly() { @Test public void getEventsAtTransition_filtersCorrectly() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 300)); addEdge(g, intervalEdge("f", "B", "C", 100, 300)); addEdge(g, timedEdge("f", "X", "Y", 200)); @@ -412,7 +412,7 @@ public void getEventsAtTransition_filtersCorrectly() { @Test public void eventCounts_sumsToTotalEvents() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, timedEdge("f", "A", "B", 100)); addEdge(g, timedEdge("f", "B", "C", 100)); addEdge(g, timedEdge("f", "X", "Y", 200)); @@ -433,7 +433,7 @@ public void eventCounts_sumsToTotalEvents() { @Test public void summary_containsKeyInfo() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); @@ -452,7 +452,7 @@ public void summary_containsKeyInfo() { @Test public void snapshot_vertexAndEdgeCounts() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); addEdge(g, intervalEdge("f", "C", "A", 100, 200)); @@ -469,7 +469,7 @@ public void snapshot_vertexAndEdgeCounts() { @Test public void snapshot_averageCommunitySize() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); @@ -484,7 +484,7 @@ public void snapshot_averageCommunitySize() { @Test public void snapshot_emptyGraph_producesEvents() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, timedEdge("f", "A", "B", 100)); addEdge(g, timedEdge("f", "X", "Y", 300)); @@ -499,7 +499,7 @@ public void snapshot_emptyGraph_producesEvents() { @Test public void topMigrants_returnsLimitedResults() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 300)); addEdge(g, intervalEdge("f", "B", "C", 100, 300)); addEdge(g, timedEdge("f", "X", "Y", 100)); @@ -517,7 +517,7 @@ public void topMigrants_returnsLimitedResults() { @Test public void minCommunitySize_filtersSingletons() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, timedEdge("f", "A", "B", 100)); addEdge(g, timedEdge("f", "X", "Y", 200)); @@ -536,7 +536,7 @@ public void minCommunitySize_filtersSingletons() { @Test public void minCommunitySize_one_includesSingletons() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); CommunityEvolutionTracker tracker = new CommunityEvolutionTracker(new TemporalGraph(g)); @@ -552,7 +552,7 @@ public void minCommunitySize_one_includesSingletons() { @Test public void track_withWindows_producesSnapshots() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 400)); addEdge(g, intervalEdge("f", "B", "C", 100, 400)); addEdge(g, timedEdge("f", "X", "Y", 300)); @@ -569,7 +569,7 @@ public void track_withWindows_producesSnapshots() { @Test public void eventToString_containsType() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, timedEdge("f", "A", "B", 100)); addEdge(g, timedEdge("f", "B", "C", 100)); addEdge(g, timedEdge("f", "X", "Y", 200)); @@ -590,7 +590,7 @@ public void eventToString_containsType() { @Test public void nodeLineageEntry_toString() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); @@ -611,7 +611,7 @@ public void nodeLineageEntry_toString() { @Test public void snapshotToString_containsCounts() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); @@ -629,7 +629,7 @@ public void snapshotToString_containsCounts() { @Test public void complexScenario_multiPhaseEvolution() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); // Persistent edges within sub-groups addEdge(g, intervalEdge("f", "Alice", "Bob", 100, 300)); @@ -669,7 +669,7 @@ public void complexScenario_multiPhaseEvolution() { @Test public void highMatchThreshold_runs() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); addEdge(g, timedEdge("f", "C", "D", 100)); @@ -685,7 +685,7 @@ public void highMatchThreshold_runs() { @Test public void lowChangeThreshold_runs() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); addEdge(g, timedEdge("f", "C", "D", 200)); @@ -702,7 +702,7 @@ public void lowChangeThreshold_runs() { @Test public void eventProperties_accessible() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, timedEdge("f", "A", "B", 100)); addEdge(g, timedEdge("f", "B", "C", 100)); addEdge(g, timedEdge("f", "X", "Y", 200)); @@ -726,7 +726,7 @@ public void eventProperties_accessible() { @Test public void snapshot_totalMembers() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); addEdge(g, intervalEdge("f", "X", "Y", 100, 200)); @@ -743,7 +743,7 @@ public void snapshot_totalMembers() { @Test public void nodeLineageEntry_properties() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); addEdge(g, intervalEdge("f", "A", "B", 100, 200)); addEdge(g, intervalEdge("f", "B", "C", 100, 200)); diff --git a/Gvisual/test/gvisual/CsvReportExporterTest.java b/Gvisual/test/gvisual/CsvReportExporterTest.java index c476096..f2098c4 100644 --- a/Gvisual/test/gvisual/CsvReportExporterTest.java +++ b/Gvisual/test/gvisual/CsvReportExporterTest.java @@ -25,7 +25,7 @@ public void testNullGraphThrows() { @Test public void testNullEdgeListAccepted() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); CsvReportExporter exporter = new CsvReportExporter(g, null); assertNotNull(exporter.exportToString()); } @@ -34,8 +34,8 @@ public void testNullEdgeListAccepted() { @Test public void testEmptyGraphProducesHeaderOnly() { - Graph g = new UndirectedSparseGraph<>(); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + Graph g = new UndirectedSparseGraph<>(); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); exporter.setTimestamp("2026-01-01 00:00:00"); String csv = exporter.exportToString(); @@ -51,9 +51,9 @@ public void testEmptyGraphProducesHeaderOnly() { @Test public void testSingleNodeNoEdges() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("Alice"); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); String csv = exporter.exportToString(); assertTrue(csv.contains("Nodes: 1")); @@ -65,12 +65,12 @@ public void testSingleNodeNoEdges() { @Test public void testTriangleGraphMetrics() { - Graph g = new UndirectedSparseGraph<>(); - List edges = new ArrayList<>(); + Graph g = new UndirectedSparseGraph<>(); + List edges = new ArrayList<>(); - edge e1 = new edge("f", "A", "B"); - edge e2 = new edge("f", "B", "C"); - edge e3 = new edge("f", "A", "C"); + edge e1 = new Edge("f", "A", "B"); + edge e2 = new Edge("f", "B", "C"); + edge e3 = new Edge("f", "A", "C"); edges.add(e1); edges.add(e2); edges.add(e3); @@ -104,11 +104,11 @@ public void testTriangleGraphMetrics() { @Test public void testBridgeGraphHasArticulationPoint() { // A-B-C where B is an articulation point - Graph g = new UndirectedSparseGraph<>(); - List edges = new ArrayList<>(); + Graph g = new UndirectedSparseGraph<>(); + List edges = new ArrayList<>(); - edge e1 = new edge("f", "A", "B"); - edge e2 = new edge("c", "B", "C"); + edge e1 = new Edge("f", "A", "B"); + edge e2 = new Edge("c", "B", "C"); edges.add(e1); edges.add(e2); g.addEdge(e1, "A", "B"); @@ -142,12 +142,12 @@ public void testBridgeGraphHasArticulationPoint() { @Test public void testEdgeTypeCounts() { - Graph g = new UndirectedSparseGraph<>(); - List edges = new ArrayList<>(); + Graph g = new UndirectedSparseGraph<>(); + List edges = new ArrayList<>(); - edge e1 = new edge("f", "X", "Y"); // friend - edge e2 = new edge("fs", "X", "Z"); // familiar stranger - edge e3 = new edge("sg", "Y", "Z"); // study group + edge e1 = new Edge("f", "X", "Y"); // friend + edge e2 = new Edge("fs", "X", "Z"); // familiar stranger + edge e3 = new Edge("sg", "Y", "Z"); // study group edges.add(e1); edges.add(e2); edges.add(e3); @@ -174,9 +174,9 @@ public void testEdgeTypeCounts() { @Test public void testNodeNameWithCommaIsEscaped() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("Last, First"); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); String csv = exporter.exportToString(); assertTrue("Comma in node name should be quoted", csv.contains("\"Last, First\"")); @@ -186,9 +186,9 @@ public void testNodeNameWithCommaIsEscaped() { @Test public void testExportToFile() throws IOException { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("Solo"); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); File tempFile = File.createTempFile("graph-report-", ".csv"); tempFile.deleteOnExit(); @@ -203,8 +203,8 @@ public void testExportToFile() throws IOException { @Test public void testSetTimestamp() { - Graph g = new UndirectedSparseGraph<>(); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + Graph g = new UndirectedSparseGraph<>(); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); exporter.setTimestamp("2099-12-31 23:59:59"); String csv = exporter.exportToString(); assertTrue(csv.contains("2099-12-31 23:59:59")); @@ -214,11 +214,11 @@ public void testSetTimestamp() { @Test public void testNodeOutputIsSorted() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("Charlie"); g.addVertex("Alice"); g.addVertex("Bob"); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); String csv = exporter.exportToString(); int idxA = csv.indexOf("Alice,"); @@ -232,9 +232,9 @@ public void testNodeOutputIsSorted() { @Test public void testFormulaInjectionNodeEquals() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("=CMD()"); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); String csv = exporter.exportToString(); assertTrue("Formula prefix defused", csv.contains("\"'=CMD()\"")); assertFalse("Raw formula not present", csv.contains(",=CMD(),")); @@ -242,36 +242,36 @@ public void testFormulaInjectionNodeEquals() { @Test public void testFormulaInjectionNodePlus() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("+1234"); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); String csv = exporter.exportToString(); assertTrue("Plus-prefix defused", csv.contains("\"'+1234\"")); } @Test public void testFormulaInjectionNodeMinus() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("-DROP"); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); String csv = exporter.exportToString(); assertTrue("Minus-prefix defused", csv.contains("\"'-DROP\"")); } @Test public void testFormulaInjectionNodeAt() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("@SUM(A1:A10)"); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); String csv = exporter.exportToString(); assertTrue("At-prefix defused", csv.contains("\"'@SUM(A1:A10)\"")); } @Test public void testSafeNodeNotPrefixed() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("Alice"); - CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); + CsvReportExporter exporter = new CsvReportExporter(g, new ArrayList()); String csv = exporter.exportToString(); assertTrue("Safe name present", csv.contains("Alice,")); assertFalse("No spurious quoting", csv.contains("\"'Alice\"")); diff --git a/Gvisual/test/gvisual/CycleAnalyzerTest.java b/Gvisual/test/gvisual/CycleAnalyzerTest.java index abe0694..e3aec61 100644 --- a/Gvisual/test/gvisual/CycleAnalyzerTest.java +++ b/Gvisual/test/gvisual/CycleAnalyzerTest.java @@ -17,44 +17,44 @@ public class CycleAnalyzerTest { // ── Helper methods ────────────────────────────────────────── - private Graph buildUndirected(String[][] edges) { - Graph g = new UndirectedSparseGraph(); + private Graph buildUndirected(String[][] edges) { + Graph g = new UndirectedSparseGraph(); int id = 0; for (String[] e : edges) { if (!g.containsVertex(e[0])) g.addVertex(e[0]); if (!g.containsVertex(e[1])) g.addVertex(e[1]); - edge ed = new edge("link", e[0], e[1]); + edge ed = new Edge("link", e[0], e[1]); ed.setLabel("e" + id++); g.addEdge(ed, e[0], e[1]); } return g; } - private Graph buildDirected(String[][] edges) { - Graph g = new DirectedSparseGraph(); + private Graph buildDirected(String[][] edges) { + Graph g = new DirectedSparseGraph(); int id = 0; for (String[] e : edges) { if (!g.containsVertex(e[0])) g.addVertex(e[0]); if (!g.containsVertex(e[1])) g.addVertex(e[1]); - edge ed = new edge("link", e[0], e[1]); + edge ed = new Edge("link", e[0], e[1]); ed.setLabel("e" + id++); g.addEdge(ed, e[0], e[1]); } return g; } - private Graph emptyUndirected() { - return new UndirectedSparseGraph(); + private Graph emptyUndirected() { + return new UndirectedSparseGraph(); } - private Graph emptyDirected() { - return new DirectedSparseGraph(); + private Graph emptyDirected() { + return new DirectedSparseGraph(); } - private Graph singleVertex(boolean directed) { - Graph g = directed - ? new DirectedSparseGraph() - : new UndirectedSparseGraph(); + private Graph singleVertex(boolean directed) { + Graph g = directed + ? new DirectedSparseGraph() + : new UndirectedSparseGraph(); g.addVertex("A"); return g; } @@ -80,7 +80,7 @@ public void hasCycles_singleVertexUndirected_false() { @Test public void hasCycles_treeUndirected_false() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"B", "D"} }); assertFalse(new CycleAnalyzer(g).hasCycles()); @@ -88,7 +88,7 @@ public void hasCycles_treeUndirected_false() { @Test public void hasCycles_triangleUndirected_true() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); assertTrue(new CycleAnalyzer(g).hasCycles()); @@ -96,7 +96,7 @@ public void hasCycles_triangleUndirected_true() { @Test public void hasCycles_squareUndirected_true() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "A"} }); assertTrue(new CycleAnalyzer(g).hasCycles()); @@ -104,7 +104,7 @@ public void hasCycles_squareUndirected_true() { @Test public void hasCycles_disconnectedWithOneCyclic_true() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"}, // triangle {"D", "E"} // separate tree edge }); @@ -125,7 +125,7 @@ public void hasCycles_singleVertexDirected_false() { @Test public void hasCycles_dagDirected_false() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "B"}, {"A", "C"}, {"B", "D"}, {"C", "D"} }); assertFalse(new CycleAnalyzer(g).hasCycles()); @@ -133,7 +133,7 @@ public void hasCycles_dagDirected_false() { @Test public void hasCycles_directedTriangle_true() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); assertTrue(new CycleAnalyzer(g).hasCycles()); @@ -141,7 +141,7 @@ public void hasCycles_directedTriangle_true() { @Test public void hasCycles_selfLoop_directed_true() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "A"} }); assertTrue(new CycleAnalyzer(g).hasCycles()); @@ -149,7 +149,7 @@ public void hasCycles_selfLoop_directed_true() { @Test public void hasCycles_twoNodeCycleDirected_true() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "B"}, {"B", "A"} }); assertTrue(new CycleAnalyzer(g).hasCycles()); @@ -164,7 +164,7 @@ public void girth_emptyGraph_negative1() { @Test public void girth_tree_negative1() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "D"} }); assertEquals(-1, new CycleAnalyzer(g).girth()); @@ -172,7 +172,7 @@ public void girth_tree_negative1() { @Test public void girth_triangle_3() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); assertEquals(3, new CycleAnalyzer(g).girth()); @@ -180,7 +180,7 @@ public void girth_triangle_3() { @Test public void girth_square_4() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "A"} }); assertEquals(4, new CycleAnalyzer(g).girth()); @@ -189,7 +189,7 @@ public void girth_square_4() { @Test public void girth_squareWithDiagonal_3() { // Square ABCD with diagonal AC creates two triangles - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "A"}, {"A", "C"} }); assertEquals(3, new CycleAnalyzer(g).girth()); @@ -197,7 +197,7 @@ public void girth_squareWithDiagonal_3() { @Test public void girth_directed_triangle_3() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); assertEquals(3, new CycleAnalyzer(g).girth()); @@ -205,7 +205,7 @@ public void girth_directed_triangle_3() { @Test public void girth_directed_selfLoop_1() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "A"} }); assertEquals(1, new CycleAnalyzer(g).girth()); @@ -213,7 +213,7 @@ public void girth_directed_selfLoop_1() { @Test public void girth_directed_twoNodeCycle_2() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "B"}, {"B", "A"} }); assertEquals(2, new CycleAnalyzer(g).girth()); @@ -223,7 +223,7 @@ public void girth_directed_twoNodeCycle_2() { @Test public void fundamentalBasis_tree_empty() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"} }); List basis = new CycleAnalyzer(g).fundamentalCycleBasis(); @@ -232,7 +232,7 @@ public void fundamentalBasis_tree_empty() { @Test public void fundamentalBasis_triangle_oneCycle() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); List basis = new CycleAnalyzer(g).fundamentalCycleBasis(); @@ -243,7 +243,7 @@ public void fundamentalBasis_triangle_oneCycle() { @Test public void fundamentalBasis_squareWithDiagonal_twoCycles() { // 4 vertices, 5 edges, 1 component → cyclomatic number = 5-4+1 = 2 - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "A"}, {"A", "C"} }); List basis = new CycleAnalyzer(g).fundamentalCycleBasis(); @@ -253,7 +253,7 @@ public void fundamentalBasis_squareWithDiagonal_twoCycles() { @Test public void fundamentalBasis_K4_threeCycles() { // K4: 4 vertices, 6 edges, 1 component → 6-4+1 = 3 - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"A", "C"}, {"A", "D"}, {"B", "C"}, {"B", "D"}, {"C", "D"} }); @@ -264,7 +264,7 @@ public void fundamentalBasis_K4_threeCycles() { @Test public void fundamentalBasis_disconnected_correctCount() { // Two triangles: 6V, 6E, 2 components → 6-6+2 = 2 - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"}, {"D", "E"}, {"E", "F"}, {"F", "D"} }); @@ -283,7 +283,7 @@ public void fundamentalBasis_emptyGraph_empty() { @Test public void allCycles_tree_none() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"} }); CycleAnalyzer.CycleEnumerationResult result = @@ -294,7 +294,7 @@ public void allCycles_tree_none() { @Test public void allCycles_triangle_oneCycle() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); CycleAnalyzer.CycleEnumerationResult result = @@ -306,7 +306,7 @@ public void allCycles_triangle_oneCycle() { @Test public void allCycles_K4_sevenCycles() { // K4 has 7 simple cycles: 4 triangles + 3 four-cycles - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"A", "C"}, {"A", "D"}, {"B", "C"}, {"B", "D"}, {"C", "D"} }); @@ -318,7 +318,7 @@ public void allCycles_K4_sevenCycles() { @Test public void allCycles_directedTriangle_oneCycle() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); CycleAnalyzer.CycleEnumerationResult result = @@ -328,7 +328,7 @@ public void allCycles_directedTriangle_oneCycle() { @Test public void allCycles_directedTwoNodeCycle() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "B"}, {"B", "A"} }); CycleAnalyzer.CycleEnumerationResult result = @@ -340,7 +340,7 @@ public void allCycles_directedTwoNodeCycle() { @Test public void allCycles_limit_respectsBound() { // K4 has 7 cycles; limit to 3 - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"A", "C"}, {"A", "D"}, {"B", "C"}, {"B", "D"}, {"C", "D"} }); @@ -358,7 +358,7 @@ public void allCycles_negativeLimit_throws() { @Test public void allCycles_noDuplicates() { // Square ABCD: should find exactly 1 cycle - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "A"} }); CycleAnalyzer.CycleEnumerationResult result = @@ -369,7 +369,7 @@ public void allCycles_noDuplicates() { @Test public void allCycles_squareWithDiagonal() { // Square + diagonal: 3 cycles (2 triangles + 1 square) - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "A"}, {"A", "C"} }); CycleAnalyzer.CycleEnumerationResult result = @@ -413,11 +413,11 @@ public void cycle_notEqual_differentVertices() { @Test public void cycle_totalWeight() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); // Set weights - for (edge e : g.getEdges()) { + for (Edge e : g.getEdges()) { e.setWeight(2.0f); } CycleAnalyzer.Cycle c = new CycleAnalyzer.Cycle( @@ -441,7 +441,7 @@ public void cycle_immutableVertices() { @Test public void analyze_acyclicGraph() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"} }); CycleAnalyzer.CycleReport report = new CycleAnalyzer(g).analyze(); @@ -459,7 +459,7 @@ public void analyze_acyclicGraph() { @Test public void analyze_triangle() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); CycleAnalyzer.CycleReport report = new CycleAnalyzer(g).analyze(); @@ -475,7 +475,7 @@ public void analyze_triangle() { @Test public void analyze_K4_vertexParticipation() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"A", "C"}, {"A", "D"}, {"B", "C"}, {"B", "D"}, {"C", "D"} }); @@ -500,7 +500,7 @@ public void analyze_K4_vertexParticipation() { @Test public void analyze_summary_containsKey_info() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"} }); String summary = new CycleAnalyzer(g).analyze().getSummary(); @@ -512,7 +512,7 @@ public void analyze_summary_containsKey_info() { @Test public void analyze_summary_acyclic() { - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"} }); String summary = new CycleAnalyzer(g).analyze().getSummary(); @@ -523,7 +523,7 @@ public void analyze_summary_acyclic() { @Test public void analyze_directed_dag() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "B"}, {"A", "C"}, {"B", "D"}, {"C", "D"} }); CycleAnalyzer.CycleReport report = new CycleAnalyzer(g).analyze(); @@ -534,7 +534,7 @@ public void analyze_directed_dag() { @Test public void analyze_directed_withCycle() { - Graph g = buildDirected(new String[][] { + Graph g = buildDirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "A"}, {"C", "D"} }); CycleAnalyzer.CycleReport report = new CycleAnalyzer(g).analyze(); @@ -547,7 +547,7 @@ public void analyze_directed_withCycle() { @Test public void analyze_circumference_longestCycle() { // Pentagon: single 5-cycle - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "E"}, {"E", "A"} }); CycleAnalyzer.CycleReport report = new CycleAnalyzer(g).analyze(); @@ -559,7 +559,7 @@ public void analyze_circumference_longestCycle() { @Test public void analyze_withLimit_reportsIncomplete() { // K4 has 7 cycles, limit to 2 - Graph g = buildUndirected(new String[][] { + Graph g = buildUndirected(new String[][] { {"A", "B"}, {"A", "C"}, {"A", "D"}, {"B", "C"}, {"B", "D"}, {"C", "D"} }); diff --git a/Gvisual/test/gvisual/DegreeDistributionAnalyzerTest.java b/Gvisual/test/gvisual/DegreeDistributionAnalyzerTest.java index 9f9e6b6..ca2441f 100644 --- a/Gvisual/test/gvisual/DegreeDistributionAnalyzerTest.java +++ b/Gvisual/test/gvisual/DegreeDistributionAnalyzerTest.java @@ -15,17 +15,17 @@ */ public class DegreeDistributionAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // --- Helpers --- private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/DominatingSetAnalyzerTest.java b/Gvisual/test/gvisual/DominatingSetAnalyzerTest.java index ddaedd0..aba8be6 100644 --- a/Gvisual/test/gvisual/DominatingSetAnalyzerTest.java +++ b/Gvisual/test/gvisual/DominatingSetAnalyzerTest.java @@ -14,15 +14,15 @@ */ public class DominatingSetAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/DotExporterTest.java b/Gvisual/test/gvisual/DotExporterTest.java index 2e2a629..4cd4acd 100644 --- a/Gvisual/test/gvisual/DotExporterTest.java +++ b/Gvisual/test/gvisual/DotExporterTest.java @@ -17,8 +17,8 @@ */ public class DotExporterTest { - private Graph undirectedGraph; - private Graph directedGraph; + private Graph undirectedGraph; + private Graph directedGraph; @Before public void setUp() { @@ -27,11 +27,11 @@ public void setUp() { undirectedGraph.addVertex("A"); undirectedGraph.addVertex("B"); undirectedGraph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(2.0f); e1.setLabel("friendship"); undirectedGraph.addEdge(e1, "A", "B"); - edge e2 = new edge("c", "B", "C"); + edge e2 = new Edge("c", "B", "C"); e2.setWeight(1.0f); undirectedGraph.addEdge(e2, "B", "C"); @@ -40,10 +40,10 @@ public void setUp() { directedGraph.addVertex("X"); directedGraph.addVertex("Y"); directedGraph.addVertex("Z"); - edge d1 = new edge("s", "X", "Y"); + edge d1 = new Edge("s", "X", "Y"); d1.setWeight(3.0f); directedGraph.addEdge(d1, "X", "Y"); - edge d2 = new edge("sg", "Y", "Z"); + edge d2 = new Edge("sg", "Y", "Z"); d2.setWeight(5.0f); directedGraph.addEdge(d2, "Y", "Z"); } @@ -171,7 +171,7 @@ public void testCustomTypeColor() { @Test public void testEmptyGraph() { - Graph empty = new UndirectedSparseGraph<>(); + Graph empty = new UndirectedSparseGraph<>(); DotExporter exporter = new DotExporter(empty); String dot = exporter.exportToString(); assertTrue(dot.contains("graph G {")); @@ -195,10 +195,10 @@ public void testExportToFile() throws IOException { @Test public void testQuoteEscapesSpecialChars() { // Add a vertex with special characters - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("Node\"With\"Quotes"); g.addVertex("Normal"); - edge e = new edge("f", "Node\"With\"Quotes", "Normal"); + edge e = new Edge("f", "Node\"With\"Quotes", "Normal"); g.addEdge(e, "Node\"With\"Quotes", "Normal"); DotExporter exporter = new DotExporter(g); @@ -229,7 +229,7 @@ public void testScaleEdgesByWeightDisabled() { @Test public void testSingleVertexGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("Solo"); DotExporter exporter = new DotExporter(g); String dot = exporter.exportToString(); diff --git a/Gvisual/test/gvisual/EdgePersistenceAnalyzerTest.java b/Gvisual/test/gvisual/EdgePersistenceAnalyzerTest.java index 8d1c1b8..3201884 100644 --- a/Gvisual/test/gvisual/EdgePersistenceAnalyzerTest.java +++ b/Gvisual/test/gvisual/EdgePersistenceAnalyzerTest.java @@ -14,7 +14,7 @@ */ public class EdgePersistenceAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -45,7 +45,7 @@ public void testConstructor_negativeWindows() { @Test public void testClassify_allPersistent() { // Edge spans entire time range -> persistent in all windows - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setTimestamp(0L); e1.setEndTimestamp(1000L); graph.addEdge(e1, "A", "B"); @@ -59,11 +59,11 @@ public void testClassify_allPersistent() { @Test public void testClassify_transientEdge() { // Edge active only in a tiny window of a long timeline - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setTimestamp(0L); e1.setEndTimestamp(1000L); - edge e2 = new edge("f", "C", "D"); + edge e2 = new Edge("f", "C", "D"); e2.setTimestamp(0L); e2.setEndTimestamp(10L); // only first ~1% of range @@ -79,11 +79,11 @@ public void testClassify_transientEdge() { @Test public void testClassify_periodicEdge() { // Edge active in about half the windows - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setTimestamp(0L); e1.setEndTimestamp(1000L); // full range marker - edge e2 = new edge("f", "C", "D"); + edge e2 = new Edge("f", "C", "D"); e2.setTimestamp(0L); e2.setEndTimestamp(500L); // half the range @@ -109,7 +109,7 @@ public void testClassify_emptyGraph() { @Test public void testClassify_singleWindow() { - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setTimestamp(100L); e1.setEndTimestamp(200L); graph.addEdge(e1, "A", "B"); @@ -125,9 +125,9 @@ public void testClassify_singleWindow() { @Test public void testSummary_countsMatchClassify() { - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setTimestamp(0L); e1.setEndTimestamp(1000L); - edge e2 = new edge("f", "C", "D"); + edge e2 = new Edge("f", "C", "D"); e2.setTimestamp(0L); e2.setEndTimestamp(10L); graph.addEdge(e1, "A", "B"); @@ -145,7 +145,7 @@ public void testSummary_countsMatchClassify() { @Test public void testSummary_allKeysPresent() { - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setTimestamp(0L); e1.setEndTimestamp(100L); graph.addEdge(e1, "A", "B"); @@ -161,25 +161,25 @@ public void testSummary_allKeysPresent() { @Test public void testGetEdgesByClassification_persistent() { - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setTimestamp(0L); e1.setEndTimestamp(1000L); graph.addEdge(e1, "A", "B"); TemporalGraph tg = new TemporalGraph(graph); EdgePersistenceAnalyzer epa = new EdgePersistenceAnalyzer(tg, 5); - Set persistent = epa.getEdgesByClassification(EdgePersistenceAnalyzer.PERSISTENT); + Set persistent = epa.getEdgesByClassification(EdgePersistenceAnalyzer.PERSISTENT); assertTrue(persistent.contains(e1)); } @Test public void testGetEdgesByClassification_noMatch() { - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setTimestamp(0L); e1.setEndTimestamp(1000L); graph.addEdge(e1, "A", "B"); TemporalGraph tg = new TemporalGraph(graph); EdgePersistenceAnalyzer epa = new EdgePersistenceAnalyzer(tg, 5); - Set transient_ = epa.getEdgesByClassification(EdgePersistenceAnalyzer.TRANSIENT); + Set transient_ = epa.getEdgesByClassification(EdgePersistenceAnalyzer.TRANSIENT); assertFalse(transient_.contains(e1)); } diff --git a/Gvisual/test/gvisual/EdgeTest.java b/Gvisual/test/gvisual/EdgeTest.java index 23138dd..b4b1648 100644 --- a/Gvisual/test/gvisual/EdgeTest.java +++ b/Gvisual/test/gvisual/EdgeTest.java @@ -15,7 +15,7 @@ public class EdgeTest { @Test public void testDefaultConstructorFieldsAreNull() { - edge e = new edge(); + edge e = new Edge(); assertNull("type should be null after no-arg construction", e.getType()); assertNull("vertex1 should be null after no-arg construction", e.getVertex1()); assertNull("vertex2 should be null after no-arg construction", e.getVertex2()); @@ -25,7 +25,7 @@ public void testDefaultConstructorFieldsAreNull() { @Test public void testParameterizedConstructor() { - edge e = new edge("f", "Alice", "Bob"); + edge e = new Edge("f", "Alice", "Bob"); assertEquals("f", e.getType()); assertEquals("Alice", e.getVertex1()); assertEquals("Bob", e.getVertex2()); @@ -35,31 +35,31 @@ public void testParameterizedConstructor() { @Test public void testFriendEdgeType() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); assertEquals("f", e.getType()); } @Test public void testFamiliarStrangerEdgeType() { - edge e = new edge("fs", "A", "B"); + edge e = new Edge("fs", "A", "B"); assertEquals("fs", e.getType()); } @Test public void testClassmateEdgeType() { - edge e = new edge("c", "A", "B"); + edge e = new Edge("c", "A", "B"); assertEquals("c", e.getType()); } @Test public void testStrangerEdgeType() { - edge e = new edge("s", "A", "B"); + edge e = new Edge("s", "A", "B"); assertEquals("s", e.getType()); } @Test public void testStudyGroupEdgeType() { - edge e = new edge("sg", "A", "B"); + edge e = new Edge("sg", "A", "B"); assertEquals("sg", e.getType()); } @@ -67,28 +67,28 @@ public void testStudyGroupEdgeType() { @Test public void testSetAndGetWeight() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(42.5f); assertEquals(42.5f, e.getWeight(), 0.001f); } @Test public void testZeroWeight() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(0.0f); assertEquals(0.0f, e.getWeight(), 0.001f); } @Test public void testNegativeWeight() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(-10.0f); assertEquals(-10.0f, e.getWeight(), 0.001f); } @Test public void testLargeWeight() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(999999.99f); assertEquals(999999.99f, e.getWeight(), 1.0f); } @@ -97,14 +97,14 @@ public void testLargeWeight() { @Test public void testSetAndGetLabel() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setLabel("friend"); assertEquals("friend", e.getLabel()); } @Test public void testLabelCanBeOverwritten() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setLabel("friend"); e.setLabel("best friend"); assertEquals("best friend", e.getLabel()); @@ -112,7 +112,7 @@ public void testLabelCanBeOverwritten() { @Test public void testLabelCanBeSetToNull() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setLabel("friend"); e.setLabel(null); assertNull(e.getLabel()); @@ -120,7 +120,7 @@ public void testLabelCanBeSetToNull() { @Test public void testEmptyLabel() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setLabel(""); assertEquals("", e.getLabel()); } @@ -129,14 +129,14 @@ public void testEmptyLabel() { @Test public void testVerticesPreserveIds() { - edge e = new edge("c", "node_123", "node_456"); + edge e = new Edge("c", "node_123", "node_456"); assertEquals("node_123", e.getVertex1()); assertEquals("node_456", e.getVertex2()); } @Test public void testVerticesWithSpecialCharacters() { - edge e = new edge("f", "user@domain", "user#2"); + edge e = new Edge("f", "user@domain", "user#2"); assertEquals("user@domain", e.getVertex1()); assertEquals("user#2", e.getVertex2()); } @@ -144,7 +144,7 @@ public void testVerticesWithSpecialCharacters() { @Test public void testSelfLoop() { // edge class doesn't prevent self-loops — verify it stores them - edge e = new edge("f", "X", "X"); + edge e = new Edge("f", "X", "X"); assertEquals(e.getVertex1(), e.getVertex2()); } } diff --git a/Gvisual/test/gvisual/EulerianPathAnalyzerTest.java b/Gvisual/test/gvisual/EulerianPathAnalyzerTest.java index c8b6774..e525da1 100644 --- a/Gvisual/test/gvisual/EulerianPathAnalyzerTest.java +++ b/Gvisual/test/gvisual/EulerianPathAnalyzerTest.java @@ -20,13 +20,13 @@ public class EulerianPathAnalyzerTest { private int edgeId = 0; - private Graph newGraph() { + private Graph newGraph() { edgeId = 0; - return new UndirectedSparseGraph(); + return new UndirectedSparseGraph(); } - private void addEdge(Graph g, String v1, String v2) { - edge e = new edge("f", v1, v2); + private void addEdge(Graph g, String v1, String v2) { + edge e = new Edge("f", v1, v2); e.setLabel("e" + (edgeId++)); g.addEdge(e, v1, v2); } @@ -35,7 +35,7 @@ private void addEdge(Graph g, String v1, String v2) { @Test public void testTriangleIsEulerianCircuit() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -49,7 +49,7 @@ public void testTriangleIsEulerianCircuit() { public void testSquareWithDiagonalsIsEulerianCircuit() { // K4 minus one edge won't work; use a proper even-degree graph // Square: A-B-C-D-A, all degree 2 - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -61,7 +61,7 @@ public void testSquareWithDiagonalsIsEulerianCircuit() { @Test public void testK4IsNotEulerian() { // K4: every vertex has degree 3 (odd) - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "A", "C"); addEdge(g, "A", "D"); @@ -78,7 +78,7 @@ public void testK4IsNotEulerian() { @Test public void testSimplePathGraph() { // A-B-C: A and C have degree 1 (odd), B has degree 2 (even) - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); @@ -91,7 +91,7 @@ public void testSimplePathGraph() { public void testKoenigsbergBridges() { // Classic 7-bridges problem (simplified): 4 vertices, 7 edges // All vertices have odd degree → NOT_EULERIAN - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "A", "B"); // multi-edge simulated with different edge objects addEdge(g, "A", "C"); @@ -108,7 +108,7 @@ public void testKoenigsbergBridges() { @Test public void testFindCircuitInTriangle() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -123,7 +123,7 @@ public void testFindCircuitInTriangle() { @Test public void testFindPathInLinearGraph() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); @@ -136,7 +136,7 @@ public void testFindPathInLinearGraph() { @Test public void testNoPathInK4() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "A", "C"); addEdge(g, "A", "D"); @@ -150,7 +150,7 @@ public void testNoPathInK4() { @Test public void testFindPathVisitsAllEdges() { // House graph: square + triangle on top - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -168,7 +168,7 @@ public void testFindPathVisitsAllEdges() { @Test public void testEmptyGraph() { - Graph g = newGraph(); + Graph g = newGraph(); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); EulerianPathAnalyzer.EulerianAnalysis result = analyzer.analyze(); assertEquals(EulerianPathAnalyzer.EulerianType.EULERIAN_CIRCUIT, result.getType()); @@ -176,7 +176,7 @@ public void testEmptyGraph() { @Test public void testSingleVertex() { - Graph g = newGraph(); + Graph g = newGraph(); g.addVertex("A"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); assertEquals(EulerianPathAnalyzer.EulerianType.EULERIAN_CIRCUIT, analyzer.analyze().getType()); @@ -184,7 +184,7 @@ public void testSingleVertex() { @Test public void testSingleEdge() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); assertEquals(EulerianPathAnalyzer.EulerianType.EULERIAN_PATH, analyzer.analyze().getType()); @@ -197,7 +197,7 @@ public void testNullGraphThrows() { @Test public void testDisconnectedGraphNotEulerian() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "C", "D"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); @@ -208,7 +208,7 @@ public void testDisconnectedGraphNotEulerian() { @Test public void testIsolatedVerticesIgnored() { // Triangle + isolated vertex → still Eulerian circuit - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -221,7 +221,7 @@ public void testIsolatedVerticesIgnored() { @Test public void testDegreeMapCorrect() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -234,7 +234,7 @@ public void testDegreeMapCorrect() { @Test public void testDegreeMapImmutable() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); Map degrees = analyzer.analyze().getDegreeMap(); @@ -250,7 +250,7 @@ public void testDegreeMapImmutable() { @Test public void testSuggestEdgesForEulerianOnEulerianGraph() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -260,7 +260,7 @@ public void testSuggestEdgesForEulerianOnEulerianGraph() { @Test public void testSuggestEdgesForK4() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "A", "C"); addEdge(g, "A", "D"); @@ -276,7 +276,7 @@ public void testSuggestEdgesForK4() { @Test public void testEdgeConnectivityTriangle() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -287,7 +287,7 @@ public void testEdgeConnectivityTriangle() { @Test public void testEdgeConnectivityBridge() { // A-B-C: bridge at B - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); @@ -296,7 +296,7 @@ public void testEdgeConnectivityBridge() { @Test public void testEdgeConnectivitySingleVertex() { - Graph g = newGraph(); + Graph g = newGraph(); g.addVertex("A"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); assertEquals(0, analyzer.computeEdgeConnectivity()); @@ -306,7 +306,7 @@ public void testEdgeConnectivitySingleVertex() { @Test public void testReportContainsType() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -319,7 +319,7 @@ public void testReportContainsType() { @Test public void testReportForNonEulerian() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "A", "C"); addEdge(g, "A", "D"); @@ -335,7 +335,7 @@ public void testReportForNonEulerian() { @Test public void testReportForPath() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); @@ -347,7 +347,7 @@ public void testReportForPath() { @Test public void testMinDuplicationsEulerianCircuit() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -357,7 +357,7 @@ public void testMinDuplicationsEulerianCircuit() { @Test public void testMinDuplicationsEulerianPath() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); @@ -366,7 +366,7 @@ public void testMinDuplicationsEulerianPath() { @Test public void testMinDuplicationsK4() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "A", "C"); addEdge(g, "A", "D"); @@ -382,7 +382,7 @@ public void testMinDuplicationsK4() { @Test public void testPetersenGraphNotEulerian() { // Petersen graph: 10 vertices, 15 edges, all degree 3 - Graph g = newGraph(); + Graph g = newGraph(); // Outer cycle addEdge(g, "0", "1"); addEdge(g, "1", "2"); addEdge(g, "2", "3"); addEdge(g, "3", "4"); addEdge(g, "4", "0"); @@ -400,7 +400,7 @@ public void testPetersenGraphNotEulerian() { @Test public void testCompleteGraphK5HasEulerianCircuit() { // K5: 5 vertices, 10 edges, all degree 4 (even) → Eulerian circuit - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < v.length; i++) { for (int j = i + 1; j < v.length; j++) { @@ -418,7 +418,7 @@ public void testCompleteGraphK5HasEulerianCircuit() { @Test public void testCircuitPathReturnsToStart() { // Square graph - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -436,7 +436,7 @@ public void testCircuitPathReturnsToStart() { @Test public void testAnalysisTotalEdges() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -446,7 +446,7 @@ public void testAnalysisTotalEdges() { @Test public void testAnalysisTotalVertices() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); g.addVertex("D"); @@ -456,7 +456,7 @@ public void testAnalysisTotalVertices() { @Test public void testAnalysisConnected() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); @@ -465,7 +465,7 @@ public void testAnalysisConnected() { @Test public void testAnalysisDisconnected() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "C", "D"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); @@ -474,7 +474,7 @@ public void testAnalysisDisconnected() { @Test public void testPathResultImmutable() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -493,7 +493,7 @@ public void testPathResultImmutable() { @Test public void testStarGraphNotEulerian() { // Star with 5 leaves: center has degree 5, leaves have degree 1 - Graph g = newGraph(); + Graph g = newGraph(); for (int i = 1; i <= 5; i++) { addEdge(g, "center", "leaf" + i); } @@ -504,7 +504,7 @@ public void testStarGraphNotEulerian() { @Test public void testStarWithEvenLeaves() { // Star with 2 leaves: center degree 2, leaves degree 1 → Eulerian path - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "center", "A"); addEdge(g, "center", "B"); EulerianPathAnalyzer analyzer = new EulerianPathAnalyzer(g); diff --git a/Gvisual/test/gvisual/FeedbackVertexSetAnalyzerTest.java b/Gvisual/test/gvisual/FeedbackVertexSetAnalyzerTest.java index 7caf54d..f74f5de 100644 --- a/Gvisual/test/gvisual/FeedbackVertexSetAnalyzerTest.java +++ b/Gvisual/test/gvisual/FeedbackVertexSetAnalyzerTest.java @@ -14,22 +14,22 @@ */ public class FeedbackVertexSetAnalyzerTest { - private Graph emptyGraph; - private Graph singleVertex; - private Graph singleEdge; - private Graph triangle; - private Graph path4; - private Graph star5; - private Graph cycle4; - private Graph cycle5; - private Graph complete4; - private Graph twoCycles; - private Graph diamond; - private Graph petersen; + private Graph emptyGraph; + private Graph singleVertex; + private Graph singleEdge; + private Graph triangle; + private Graph path4; + private Graph star5; + private Graph cycle4; + private Graph cycle5; + private Graph complete4; + private Graph twoCycles; + private Graph diamond; + private Graph petersen; private int edgeId = 0; - private edge addEdge(Graph g, String u, String v) { - edge e = new edge("e", u, v); + private edge addEdge(Graph g, String u, String v) { + edge e = new Edge("e", u, v); e.setLabel("e" + (edgeId++)); g.addEdge(e, u, v); return e; @@ -412,7 +412,7 @@ public void testSingleEdge_noCycle() { @Test public void testExactEqualsOrBetterThanGreedy() { - for (Graph g : Arrays.asList(triangle, cycle4, cycle5, complete4, twoCycles, diamond)) { + for (Graph g : Arrays.asList(triangle, cycle4, cycle5, complete4, twoCycles, diamond)) { FeedbackVertexSetAnalyzer a = new FeedbackVertexSetAnalyzer(g); assertTrue(a.exactMinimumFVS().size() <= a.greedyFVS().size()); } @@ -420,7 +420,7 @@ public void testExactEqualsOrBetterThanGreedy() { @Test public void testFeedbackEdgeSetSizeEqualsCycleRank() { - for (Graph g : Arrays.asList(emptyGraph, singleVertex, singleEdge, path4, triangle, cycle5, complete4, twoCycles)) { + for (Graph g : Arrays.asList(emptyGraph, singleVertex, singleEdge, path4, triangle, cycle5, complete4, twoCycles)) { FeedbackVertexSetAnalyzer a = new FeedbackVertexSetAnalyzer(g); assertEquals(a.cycleRank(), a.feedbackEdgeSet().size()); } diff --git a/Gvisual/test/gvisual/ForceDirectedLayoutTest.java b/Gvisual/test/gvisual/ForceDirectedLayoutTest.java index b07038d..c1dc113 100644 --- a/Gvisual/test/gvisual/ForceDirectedLayoutTest.java +++ b/Gvisual/test/gvisual/ForceDirectedLayoutTest.java @@ -14,19 +14,19 @@ */ public class ForceDirectedLayoutTest { - private Graph graph; + private Graph graph; private int edgeCounter; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); edgeCounter = 0; } private edge addEdge(String v1, String v2) { graph.addVertex(v1); graph.addVertex(v2); - edge e = new edge("test", v1, v2); + edge e = new Edge("test", v1, v2); e.setWeight(1.0f); graph.addEdge(e, v1, v2); edgeCounter++; @@ -520,7 +520,7 @@ public void testBarnesHutLargeGraph() { // Connected nodes should still be closer than random pairs on average double connectedDist = 0; int connectedCount = 0; - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { double[] p1 = layout.getPosition(e.getVertex1()); double[] p2 = layout.getPosition(e.getVertex2()); if (p1 != null && p2 != null) { diff --git a/Gvisual/test/gvisual/GexfExporterTest.java b/Gvisual/test/gvisual/GexfExporterTest.java index 87f867e..de4a4a9 100644 --- a/Gvisual/test/gvisual/GexfExporterTest.java +++ b/Gvisual/test/gvisual/GexfExporterTest.java @@ -18,8 +18,8 @@ */ public class GexfExporterTest { - private Graph graph; - private List edges; + private Graph graph; + private List edges; @Before public void setUp() { @@ -28,12 +28,12 @@ public void setUp() { graph.addVertex("Bob"); graph.addVertex("Carol"); - edge e1 = new edge("f", "Alice", "Bob"); + edge e1 = new Edge("f", "Alice", "Bob"); e1.setWeight(3.5f); e1.setLabel("friends"); graph.addEdge(e1, "Alice", "Bob"); - edge e2 = new edge("c", "Bob", "Carol"); + edge e2 = new Edge("c", "Bob", "Carol"); e2.setWeight(1.0f); graph.addEdge(e2, "Bob", "Carol"); @@ -91,12 +91,12 @@ public void testVizDataCanBeDisabled() { @Test public void testTemporalEdgesEnableDynamicMode() { - edge e1 = new edge("f", "Alice", "Bob"); + edge e1 = new Edge("f", "Alice", "Bob"); e1.setWeight(1.0f); e1.setTimestamp(1000L); e1.setEndTimestamp(5000L); - Graph tGraph = new UndirectedSparseGraph<>(); + Graph tGraph = new UndirectedSparseGraph<>(); tGraph.addVertex("Alice"); tGraph.addVertex("Bob"); tGraph.addEdge(e1, "Alice", "Bob"); @@ -129,11 +129,11 @@ public void testExportToFile() throws IOException { @Test public void testXmlEscaping() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A&B"); g.addVertex("C"); - edge e = new edge("f", "A&B", "C"); + edge e = new Edge("f", "A&B", "C"); e.setWeight(1.0f); g.addEdge(e, "A&B", "C"); @@ -148,7 +148,7 @@ public void testXmlEscaping() { @Test public void testEmptyGraph() { - Graph empty = new UndirectedSparseGraph<>(); + Graph empty = new UndirectedSparseGraph<>(); GexfExporter exporter = new GexfExporter(empty, new ArrayList<>()); String xml = exporter.exportToString(); diff --git a/Gvisual/test/gvisual/GraphAlgorithmAnimatorTest.java b/Gvisual/test/gvisual/GraphAlgorithmAnimatorTest.java index c119646..eb1a274 100644 --- a/Gvisual/test/gvisual/GraphAlgorithmAnimatorTest.java +++ b/Gvisual/test/gvisual/GraphAlgorithmAnimatorTest.java @@ -15,11 +15,11 @@ */ public class GraphAlgorithmAnimatorTest { - private Graph simpleGraph; - private Graph weightedGraph; - private Graph directedGraph; - private Graph singleNode; - private Graph disconnected; + private Graph simpleGraph; + private Graph weightedGraph; + private Graph directedGraph; + private Graph singleNode; + private Graph disconnected; @Before public void setUp() { @@ -29,10 +29,10 @@ public void setUp() { simpleGraph.addVertex("B"); simpleGraph.addVertex("C"); simpleGraph.addVertex("D"); - simpleGraph.addEdge(new edge("e", "A", "B"), "A", "B"); - simpleGraph.addEdge(new edge("e", "B", "C"), "B", "C"); - simpleGraph.addEdge(new edge("e", "C", "D"), "C", "D"); - simpleGraph.addEdge(new edge("e", "A", "C"), "A", "C"); + simpleGraph.addEdge(new Edge("e", "A", "B"), "A", "B"); + simpleGraph.addEdge(new Edge("e", "B", "C"), "B", "C"); + simpleGraph.addEdge(new Edge("e", "C", "D"), "C", "D"); + simpleGraph.addEdge(new Edge("e", "A", "C"), "A", "C"); // Weighted graph for Dijkstra/Kruskal weightedGraph = new UndirectedSparseGraph<>(); @@ -40,10 +40,10 @@ public void setUp() { weightedGraph.addVertex("B"); weightedGraph.addVertex("C"); weightedGraph.addVertex("D"); - edge e1 = new edge("e", "A", "B"); e1.setWeight(1); - edge e2 = new edge("e", "B", "C"); e2.setWeight(3); - edge e3 = new edge("e", "A", "C"); e3.setWeight(5); - edge e4 = new edge("e", "C", "D"); e4.setWeight(2); + edge e1 = new Edge("e", "A", "B"); e1.setWeight(1); + edge e2 = new Edge("e", "B", "C"); e2.setWeight(3); + edge e3 = new Edge("e", "A", "C"); e3.setWeight(5); + edge e4 = new Edge("e", "C", "D"); e4.setWeight(2); weightedGraph.addEdge(e1, "A", "B"); weightedGraph.addEdge(e2, "B", "C"); weightedGraph.addEdge(e3, "A", "C"); @@ -54,9 +54,9 @@ public void setUp() { directedGraph.addVertex("A"); directedGraph.addVertex("B"); directedGraph.addVertex("C"); - directedGraph.addEdge(new edge("e", "A", "B"), "A", "B"); - directedGraph.addEdge(new edge("e", "B", "C"), "B", "C"); - directedGraph.addEdge(new edge("e", "C", "A"), "C", "A"); + directedGraph.addEdge(new Edge("e", "A", "B"), "A", "B"); + directedGraph.addEdge(new Edge("e", "B", "C"), "B", "C"); + directedGraph.addEdge(new Edge("e", "C", "A"), "C", "A"); // Single node singleNode = new UndirectedSparseGraph<>(); @@ -67,7 +67,7 @@ public void setUp() { disconnected.addVertex("A"); disconnected.addVertex("B"); disconnected.addVertex("C"); - disconnected.addEdge(new edge("e", "A", "B"), "A", "B"); + disconnected.addEdge(new Edge("e", "A", "B"), "A", "B"); // C is isolated } diff --git a/Gvisual/test/gvisual/GraphAnnotationManagerTest.java b/Gvisual/test/gvisual/GraphAnnotationManagerTest.java index 68a34ba..243d4a4 100644 --- a/Gvisual/test/gvisual/GraphAnnotationManagerTest.java +++ b/Gvisual/test/gvisual/GraphAnnotationManagerTest.java @@ -267,15 +267,15 @@ public void testGetSummary() { @Test public void testAutoTagByDegree() { - Graph graph = new UndirectedSparseGraph<>(); + Graph graph = new UndirectedSparseGraph<>(); graph.addVertex("hub"); graph.addVertex("leaf1"); graph.addVertex("leaf2"); graph.addVertex("leaf3"); graph.addVertex("isolated"); - graph.addEdge(new edge("f", "hub", "leaf1"), "hub", "leaf1"); - graph.addEdge(new edge("f", "hub", "leaf2"), "hub", "leaf2"); - graph.addEdge(new edge("f", "hub", "leaf3"), "hub", "leaf3"); + graph.addEdge(new Edge("f", "hub", "leaf1"), "hub", "leaf1"); + graph.addEdge(new Edge("f", "hub", "leaf2"), "hub", "leaf2"); + graph.addEdge(new Edge("f", "hub", "leaf3"), "hub", "leaf3"); int count = manager.autoTagByDegree(graph, 3, 0); assertTrue(count > 0); @@ -285,11 +285,11 @@ public void testAutoTagByDegree() { @Test public void testAutoTagIsolated() { - Graph graph = new UndirectedSparseGraph<>(); + Graph graph = new UndirectedSparseGraph<>(); graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); int count = manager.autoTagIsolated(graph); assertEquals(1, count); diff --git a/Gvisual/test/gvisual/GraphAnomalyDetectorTest.java b/Gvisual/test/gvisual/GraphAnomalyDetectorTest.java index c546f1d..13f32b0 100644 --- a/Gvisual/test/gvisual/GraphAnomalyDetectorTest.java +++ b/Gvisual/test/gvisual/GraphAnomalyDetectorTest.java @@ -14,11 +14,11 @@ */ public class GraphAnomalyDetectorTest { - private Graph graph; + private Graph graph; /** Creates an edge with the given type and weight. */ private edge makeEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); return e; } @@ -33,7 +33,7 @@ private edge makeEdge(String type, String v1, String v2, float weight) { */ @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); // Add hub String hub = "0"; @@ -92,7 +92,7 @@ public void testAnalyzeReturnsThis() { @Test(expected = IllegalStateException.class) public void testAnalyzeTooFewVertices() { - Graph tiny = new UndirectedSparseGraph(); + Graph tiny = new UndirectedSparseGraph(); tiny.addVertex("A"); tiny.addVertex("B"); edge e = makeEdge("f", "A", "B", 1.0f); @@ -102,7 +102,7 @@ public void testAnalyzeTooFewVertices() { @Test public void testAnalyzeThreeVerticesMinimum() { - Graph small = new UndirectedSparseGraph(); + Graph small = new UndirectedSparseGraph(); small.addVertex("A"); small.addVertex("B"); small.addVertex("C"); @@ -437,7 +437,7 @@ public void testReanalyzeGivesSameResults() { @Test public void testUniformGraphLowScores() { // Ring graph: all nodes have degree 2, same clustering, same diversity - Graph ring = new UndirectedSparseGraph(); + Graph ring = new UndirectedSparseGraph(); for (int i = 0; i < 6; i++) { ring.addVertex(String.valueOf(i)); } @@ -460,7 +460,7 @@ public void testUniformGraphLowScores() { @Test public void testStarGraphHubIsAnomaly() { - Graph star = new UndirectedSparseGraph(); + Graph star = new UndirectedSparseGraph(); star.addVertex("center"); for (int i = 0; i < 10; i++) { String leaf = "leaf" + i; @@ -480,7 +480,7 @@ public void testStarGraphHubIsAnomaly() { @Test public void testCompleteGraphAllSimilar() { - Graph complete = new UndirectedSparseGraph(); + Graph complete = new UndirectedSparseGraph(); String[] nodes = {"A", "B", "C", "D"}; for (String n : nodes) complete.addVertex(n); diff --git a/Gvisual/test/gvisual/GraphAsciiRendererTest.java b/Gvisual/test/gvisual/GraphAsciiRendererTest.java index 5de1fb7..8ece5a1 100644 --- a/Gvisual/test/gvisual/GraphAsciiRendererTest.java +++ b/Gvisual/test/gvisual/GraphAsciiRendererTest.java @@ -19,10 +19,10 @@ */ public class GraphAsciiRendererTest { - private Graph emptyGraph; - private Graph singleNodeGraph; - private Graph triangleGraph; - private Graph starGraph; + private Graph emptyGraph; + private Graph singleNodeGraph; + private Graph triangleGraph; + private Graph starGraph; @Before public void setUp() { @@ -36,11 +36,11 @@ public void setUp() { triangleGraph.addVertex("A"); triangleGraph.addVertex("B"); triangleGraph.addVertex("C"); - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("c", "B", "C"); + edge e2 = new Edge("c", "B", "C"); e2.setWeight(2.0f); - edge e3 = new edge("f", "C", "A"); + edge e3 = new Edge("f", "C", "A"); e3.setWeight(1.5f); triangleGraph.addEdge(e1, "A", "B"); triangleGraph.addEdge(e2, "B", "C"); @@ -52,7 +52,7 @@ public void setUp() { for (int i = 1; i <= 4; i++) { String leaf = "Leaf" + i; starGraph.addVertex(leaf); - edge e = new edge("f", "Center", leaf); + edge e = new Edge("f", "Center", leaf); e.setWeight(1.0f); starGraph.addEdge(e, "Center", leaf); } @@ -328,12 +328,12 @@ public void minimalLayoutIterationsStillRenders() { @Test public void largeGraphRendersWithoutError() { - Graph large = new UndirectedSparseGraph<>(); + Graph large = new UndirectedSparseGraph<>(); for (int i = 0; i < 50; i++) { large.addVertex("N" + i); } for (int i = 0; i < 49; i++) { - edge e = new edge("f", "N" + i, "N" + (i + 1)); + edge e = new Edge("f", "N" + i, "N" + (i + 1)); e.setWeight(1.0f); large.addEdge(e, "N" + i, "N" + (i + 1)); } diff --git a/Gvisual/test/gvisual/GraphBenchmarkSuiteTest.java b/Gvisual/test/gvisual/GraphBenchmarkSuiteTest.java index 16d145f..5982b20 100644 --- a/Gvisual/test/gvisual/GraphBenchmarkSuiteTest.java +++ b/Gvisual/test/gvisual/GraphBenchmarkSuiteTest.java @@ -17,7 +17,7 @@ public class GraphBenchmarkSuiteTest { assertTrue(bg.verify()); } @Test public void testZacharyKeyNodes() { - Graph g = suite.zacharyKarateClub().getGraph(); + Graph g = suite.zacharyKarateClub().getGraph(); assertTrue(g.containsVertex("1")); assertTrue(g.containsVertex("34")); assertTrue(g.degree("1") >= 16); @@ -32,7 +32,7 @@ public class GraphBenchmarkSuiteTest { assertTrue(bg.verify()); } @Test public void testPetersenThreeRegular() { - Graph g = suite.petersenGraph().getGraph(); + Graph g = suite.petersenGraph().getGraph(); for (String v : g.getVertices()) assertEquals(3, g.degree(v)); } @Test public void testPetersenNotHamiltonian() { @@ -45,12 +45,12 @@ public class GraphBenchmarkSuiteTest { assertTrue(bg.verify()); } @Test public void testFlorentineMediciHighest() { - Graph g = suite.florentineFamilies().getGraph(); + Graph g = suite.florentineFamilies().getGraph(); int md = g.degree("Medici"); for (String v : g.getVertices()) assertTrue(md >= g.degree(v)); } @Test public void testFlorentineNames() { - Graph g = suite.florentineFamilies().getGraph(); + Graph g = suite.florentineFamilies().getGraph(); assertTrue(g.containsVertex("Strozzi")); assertTrue(g.containsVertex("Albizzi")); } @@ -104,7 +104,7 @@ public class GraphBenchmarkSuiteTest { assertEquals(8, suite.friendshipGraph(4).getGraph().degree("0")); } @Test public void testFriendshipLeafDegree() { - Graph g = suite.friendshipGraph(3).getGraph(); + Graph g = suite.friendshipGraph(3).getGraph(); for (String v : g.getVertices()) if (!v.equals("0")) assertEquals(2, g.degree(v)); } diff --git a/Gvisual/test/gvisual/GraphCentralityCorrelatorTest.java b/Gvisual/test/gvisual/GraphCentralityCorrelatorTest.java index 52f675f..e3fc0e4 100644 --- a/Gvisual/test/gvisual/GraphCentralityCorrelatorTest.java +++ b/Gvisual/test/gvisual/GraphCentralityCorrelatorTest.java @@ -15,17 +15,17 @@ */ public class GraphCentralityCorrelatorTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // --- Helper methods --- private edge addEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/GraphClusterQualityAnalyzerTest.java b/Gvisual/test/gvisual/GraphClusterQualityAnalyzerTest.java index 1f35419..c3d600f 100644 --- a/Gvisual/test/gvisual/GraphClusterQualityAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphClusterQualityAnalyzerTest.java @@ -14,11 +14,11 @@ */ public class GraphClusterQualityAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // ── Helper methods ────────────────────────────────────────── @@ -26,7 +26,7 @@ public void setUp() { private void addEdge(String v1, String v2, String type) { graph.addVertex(v1); graph.addVertex(v2); - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); graph.addEdge(e, v1, v2); } diff --git a/Gvisual/test/gvisual/GraphColoringAnalyzerTest.java b/Gvisual/test/gvisual/GraphColoringAnalyzerTest.java index 0a4f28b..dec9c71 100644 --- a/Gvisual/test/gvisual/GraphColoringAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphColoringAnalyzerTest.java @@ -15,12 +15,12 @@ */ public class GraphColoringAnalyzerTest { - private Graph graph; + private Graph graph; private int edgeCounter; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); edgeCounter = 0; } @@ -858,7 +858,7 @@ public void testWelshPowellPrioritizesHighDegree() { // ========================================== private void addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setLabel("e" + (edgeCounter++)); graph.addEdge(e, v1, v2); } diff --git a/Gvisual/test/gvisual/GraphDiameterAnalyzerTest.java b/Gvisual/test/gvisual/GraphDiameterAnalyzerTest.java index a7111ed..46615f5 100644 --- a/Gvisual/test/gvisual/GraphDiameterAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphDiameterAnalyzerTest.java @@ -15,11 +15,11 @@ */ public class GraphDiameterAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } @Test(expected = IllegalArgumentException.class) @@ -60,9 +60,9 @@ public void linearGraph() { graph.addVertex("B"); graph.addVertex("C"); graph.addVertex("D"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "B", "C"), "B", "C"); - graph.addEdge(new edge("f", "C", "D"), "C", "D"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "B", "C"), "B", "C"); + graph.addEdge(new Edge("f", "C", "D"), "C", "D"); GraphDiameterAnalyzer analyzer = new GraphDiameterAnalyzer(graph); analyzer.analyze(); @@ -85,7 +85,7 @@ public void completeGraph() { int edgeId = 0; for (int i = 0; i < verts.length; i++) { for (int j = i + 1; j < verts.length; j++) { - graph.addEdge(new edge("f", verts[i], verts[j]), verts[i], verts[j]); + graph.addEdge(new Edge("f", verts[i], verts[j]), verts[i], verts[j]); } } @@ -105,7 +105,7 @@ public void starGraph() { for (int i = 1; i <= 4; i++) { String leaf = "L" + i; graph.addVertex(leaf); - graph.addEdge(new edge("f", "H", leaf), "H", leaf); + graph.addEdge(new Edge("f", "H", leaf), "H", leaf); } GraphDiameterAnalyzer analyzer = new GraphDiameterAnalyzer(graph); @@ -127,9 +127,9 @@ public void disconnectedGraphUsesLargestComponent() { graph.addVertex("C"); graph.addVertex("X"); graph.addVertex("Y"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "B", "C"), "B", "C"); - graph.addEdge(new edge("f", "X", "Y"), "X", "Y"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "B", "C"), "B", "C"); + graph.addEdge(new Edge("f", "X", "Y"), "X", "Y"); GraphDiameterAnalyzer analyzer = new GraphDiameterAnalyzer(graph); analyzer.analyze(); @@ -147,8 +147,8 @@ public void eccentricityValues() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "B", "C"), "B", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "B", "C"), "B", "C"); GraphDiameterAnalyzer analyzer = new GraphDiameterAnalyzer(graph); analyzer.analyze(); @@ -162,7 +162,7 @@ public void eccentricityValues() { public void summaryContainsKey() { graph.addVertex("A"); graph.addVertex("B"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); GraphDiameterAnalyzer analyzer = new GraphDiameterAnalyzer(graph); analyzer.analyze(); @@ -179,8 +179,8 @@ public void rankedByEccentricityIsSorted() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "B", "C"), "B", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "B", "C"), "B", "C"); GraphDiameterAnalyzer analyzer = new GraphDiameterAnalyzer(graph); analyzer.analyze(); diff --git a/Gvisual/test/gvisual/GraphDiffAnalyzerTest.java b/Gvisual/test/gvisual/GraphDiffAnalyzerTest.java index 1df4ea3..cf480b0 100644 --- a/Gvisual/test/gvisual/GraphDiffAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphDiffAnalyzerTest.java @@ -16,8 +16,8 @@ */ public class GraphDiffAnalyzerTest { - private Graph graphA; - private Graph graphB; + private Graph graphA; + private Graph graphB; @Before public void setUp() { @@ -25,10 +25,10 @@ public void setUp() { graphB = new UndirectedSparseGraph<>(); } - private void addEdge(Graph g, String v1, String v2) { + private void addEdge(Graph g, String v1, String v2) { if (!g.containsVertex(v1)) g.addVertex(v1); if (!g.containsVertex(v2)) g.addVertex(v2); - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); g.addEdge(e, v1, v2); } diff --git a/Gvisual/test/gvisual/GraphDistanceDistributionTest.java b/Gvisual/test/gvisual/GraphDistanceDistributionTest.java index b18d022..6debf8e 100644 --- a/Gvisual/test/gvisual/GraphDistanceDistributionTest.java +++ b/Gvisual/test/gvisual/GraphDistanceDistributionTest.java @@ -16,34 +16,34 @@ public class GraphDistanceDistributionTest { // --- helpers --- - private Graph makePath(int n) { - Graph g = new UndirectedSparseGraph<>(); + private Graph makePath(int n) { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < n; i++) g.addVertex("v" + i); for (int i = 0; i < n - 1; i++) { - g.addEdge(new edge("e", "v" + i, "v" + (i + 1)), "v" + i, "v" + (i + 1)); + g.addEdge(new Edge("e", "v" + i, "v" + (i + 1)), "v" + i, "v" + (i + 1)); } return g; } - private Graph makeComplete(int n) { - Graph g = new UndirectedSparseGraph<>(); + private Graph makeComplete(int n) { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < n; i++) g.addVertex("v" + i); int id = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { - g.addEdge(new edge("e" + id++, "v" + i, "v" + j), "v" + i, "v" + j); + g.addEdge(new Edge("e" + id++, "v" + i, "v" + j), "v" + i, "v" + j); } } return g; } - private Graph makeStar(int leaves) { - Graph g = new UndirectedSparseGraph<>(); + private Graph makeStar(int leaves) { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("center"); for (int i = 0; i < leaves; i++) { String leaf = "leaf" + i; g.addVertex(leaf); - g.addEdge(new edge("e" + i, "center", leaf), "center", leaf); + g.addEdge(new Edge("e" + i, "center", leaf), "center", leaf); } return g; } @@ -65,7 +65,7 @@ public void testNotComputed() { @Test public void testEmptyGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); GraphDistanceDistribution dd = new GraphDistanceDistribution(g); dd.compute(); assertEquals(0.0, dd.getAveragePathLength(), 0.001); @@ -76,7 +76,7 @@ public void testEmptyGraph() { @Test public void testSingleVertex() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("a"); GraphDistanceDistribution dd = new GraphDistanceDistribution(g); dd.compute(); @@ -177,11 +177,11 @@ public void testConnectedSeparation() { @Test public void testDisconnectedSeparation() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("a"); g.addVertex("b"); g.addVertex("c"); - g.addEdge(new edge("e1", "a", "b"), "a", "b"); + g.addEdge(new Edge("e1", "a", "b"), "a", "b"); // c is isolated → 2 out of 3 pairs unreachable GraphDistanceDistribution dd = new GraphDistanceDistribution(g); dd.compute(); @@ -201,7 +201,7 @@ public void testHarmonicMeanComplete() { @Test public void testHarmonicMeanDisconnected() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("a"); g.addVertex("b"); // No edges → infinite harmonic mean @@ -247,7 +247,7 @@ public void testDistinctDistancesComplete() { @Test public void testUnreachableDistance() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("a"); g.addVertex("b"); GraphDistanceDistribution dd = new GraphDistanceDistribution(g); @@ -266,7 +266,7 @@ public void testNonexistentVertex() { @Test public void testRemotenessIsolated() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("a"); GraphDistanceDistribution dd = new GraphDistanceDistribution(g); dd.compute(); @@ -318,12 +318,12 @@ public void testHistogramJson() { @Test public void testDirectedGraph() { - Graph g = new DirectedSparseGraph<>(); + Graph g = new DirectedSparseGraph<>(); g.addVertex("a"); g.addVertex("b"); g.addVertex("c"); - g.addEdge(new edge("e1", "a", "b"), "a", "b"); - g.addEdge(new edge("e2", "b", "c"), "b", "c"); + g.addEdge(new Edge("e1", "a", "b"), "a", "b"); + g.addEdge(new Edge("e2", "b", "c"), "b", "c"); // a→b→c but no reverse GraphDistanceDistribution dd = new GraphDistanceDistribution(g); dd.compute(); @@ -357,13 +357,13 @@ public void testRecompute() { @Test public void testTwoComponents() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("a"); g.addVertex("b"); - g.addEdge(new edge("e1", "a", "b"), "a", "b"); + g.addEdge(new Edge("e1", "a", "b"), "a", "b"); g.addVertex("c"); g.addVertex("d"); - g.addEdge(new edge("e2", "c", "d"), "c", "d"); + g.addEdge(new Edge("e2", "c", "d"), "c", "d"); GraphDistanceDistribution dd = new GraphDistanceDistribution(g); dd.compute(); assertEquals(1, dd.getDistance("a", "b")); @@ -379,7 +379,7 @@ public void testTwoComponents() { @Test public void testPercentileEmpty() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("a"); GraphDistanceDistribution dd = new GraphDistanceDistribution(g); dd.compute(); @@ -390,11 +390,11 @@ public void testPercentileEmpty() { @Test public void testCycleGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < 6; i++) g.addVertex("v" + i); for (int i = 0; i < 6; i++) { int j = (i + 1) % 6; - g.addEdge(new edge("e" + i, "v" + i, "v" + j), "v" + i, "v" + j); + g.addEdge(new Edge("e" + i, "v" + i, "v" + j), "v" + i, "v" + j); } GraphDistanceDistribution dd = new GraphDistanceDistribution(g); dd.compute(); diff --git a/Gvisual/test/gvisual/GraphEntropyAnalyzerTest.java b/Gvisual/test/gvisual/GraphEntropyAnalyzerTest.java index 82a813c..ab60f8c 100644 --- a/Gvisual/test/gvisual/GraphEntropyAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphEntropyAnalyzerTest.java @@ -14,7 +14,7 @@ */ public class GraphEntropyAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -28,7 +28,7 @@ private edge addEdge(String v1, String v2) { } private edge addEdge(String v1, String v2, String type) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); @@ -36,12 +36,12 @@ private edge addEdge(String v1, String v2, String type) { return e; } - private Graph completeGraph(int n) { - Graph g = new UndirectedSparseGraph<>(); + private Graph completeGraph(int n) { + Graph g = new UndirectedSparseGraph<>(); for (int i = 1; i <= n; i++) g.addVertex("N" + i); for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { - edge e = new edge("f", "N" + i, "N" + j); + edge e = new Edge("f", "N" + i, "N" + j); e.setWeight(1.0f); g.addEdge(e, "N" + i, "N" + j); } @@ -49,31 +49,31 @@ private Graph completeGraph(int n) { return g; } - private Graph pathGraph(int n) { - Graph g = new UndirectedSparseGraph<>(); + private Graph pathGraph(int n) { + Graph g = new UndirectedSparseGraph<>(); for (int i = 1; i <= n; i++) g.addVertex("N" + i); for (int i = 1; i < n; i++) { - edge e = new edge("f", "N" + i, "N" + (i + 1)); + edge e = new Edge("f", "N" + i, "N" + (i + 1)); e.setWeight(1.0f); g.addEdge(e, "N" + i, "N" + (i + 1)); } return g; } - private Graph cycleGraph(int n) { - Graph g = pathGraph(n); - edge e = new edge("f", "N" + n, "N1"); + private Graph cycleGraph(int n) { + Graph g = pathGraph(n); + edge e = new Edge("f", "N" + n, "N1"); e.setWeight(1.0f); g.addEdge(e, "N" + n, "N1"); return g; } - private Graph starGraph(int n) { - Graph g = new UndirectedSparseGraph<>(); + private Graph starGraph(int n) { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("C"); for (int i = 1; i <= n; i++) { g.addVertex("L" + i); - edge e = new edge("f", "C", "L" + i); + edge e = new Edge("f", "C", "L" + i); e.setWeight(1.0f); g.addEdge(e, "C", "L" + i); } @@ -129,7 +129,7 @@ public void testNullGraphThrows() { @Test public void testDegreeEntropyRegularGraph() { - Graph g = cycleGraph(5); + Graph g = cycleGraph(5); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertEquals(0, a.getDegreeEntropy(), 1e-10); @@ -137,7 +137,7 @@ public void testDegreeEntropyRegularGraph() { @Test public void testDegreeEntropyStarGraph() { - Graph g = starGraph(4); + Graph g = starGraph(4); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); // 1 vertex with degree 4, 4 vertices with degree 1 @@ -149,7 +149,7 @@ public void testDegreeEntropyStarGraph() { @Test public void testDegreeEntropyCompleteGraph() { - Graph g = completeGraph(5); + Graph g = completeGraph(5); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertEquals(0, a.getDegreeEntropy(), 1e-10); @@ -164,7 +164,7 @@ public void testMaxDegreeEntropy() { @Test public void testNormalisedDegreeEntropyRegular() { - Graph g = cycleGraph(6); + Graph g = cycleGraph(6); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertEquals(0, a.getNormalisedDegreeEntropy(), 1e-10); @@ -211,7 +211,7 @@ public void testVonNeumannTriangle() { @Test public void testVonNeumannPositive() { - Graph g = pathGraph(5); + Graph g = pathGraph(5); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertTrue(a.getVonNeumannEntropy() > 0); @@ -232,7 +232,7 @@ public void testVonNeumannCompleteHigherThanPath() { @Test public void testNeighbourhoodEntropyRegular() { - Graph g = cycleGraph(5); + Graph g = cycleGraph(5); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertEquals(0, a.getAvgNeighbourhoodEntropy(), 1e-10); @@ -337,7 +337,7 @@ public void testEdgeTypeEntropyNoEdges() { @Test public void testTopoInfoContentComplete() { - Graph g = completeGraph(4); + Graph g = completeGraph(4); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertEquals(0, a.getTopologicalInfoContent(), 1e-6); @@ -345,7 +345,7 @@ public void testTopoInfoContentComplete() { @Test public void testTopoInfoContentAllDifferent() { - Graph g = pathGraph(4); + Graph g = pathGraph(4); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertTrue(a.getTopologicalInfoContent() > 0); @@ -365,7 +365,7 @@ public void testTopoInfoContentSingleVertex() { @Test public void testRWEntropyRateRegular() { - Graph g = cycleGraph(6); + Graph g = cycleGraph(6); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); // C6: m=6, 2m=12, each d=2 for 6 vertices @@ -399,7 +399,7 @@ public void testRWEntropyRateNoEdges() { @Test public void testChromaticEntropyComplete() { - Graph g = completeGraph(4); + Graph g = completeGraph(4); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertEquals(Math.log(4) / Math.log(2), a.getChromaticEntropy(), 1e-10); @@ -407,7 +407,7 @@ public void testChromaticEntropyComplete() { @Test public void testChromaticEntropyBipartite() { - Graph g = pathGraph(4); + Graph g = pathGraph(4); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertEquals(1.0, a.getChromaticEntropy(), 1e-6); @@ -448,7 +448,7 @@ public void testDegreeCCMutualInfoSingleVertex() { @Test public void testDegreeCCMutualInfoRegular() { - Graph g = cycleGraph(6); + Graph g = cycleGraph(6); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertEquals(0, a.getDegreeCCMutualInfo(), 1e-10); @@ -469,7 +469,7 @@ public void testComplexityTrivialEmpty() { public void testComplexityRegularLow() { // Cycle — all vertices have same degree, but Von Neumann entropy // is non-trivial so complexity is moderate, not low - Graph g = cycleGraph(6); + Graph g = cycleGraph(6); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); String c = a.getComplexityClass(); @@ -551,7 +551,7 @@ public void testLazyCompute() { @Test public void testCompleteGraphK10() { - Graph g = completeGraph(10); + Graph g = completeGraph(10); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertEquals(0, a.getDegreeEntropy(), 1e-10); @@ -561,7 +561,7 @@ public void testCompleteGraphK10() { @Test public void testPathGraph10() { - Graph g = pathGraph(10); + Graph g = pathGraph(10); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertTrue(a.getDegreeEntropy() > 0); @@ -571,7 +571,7 @@ public void testPathGraph10() { @Test public void testStarGraph10() { - Graph g = starGraph(10); + Graph g = starGraph(10); GraphEntropyAnalyzer a = new GraphEntropyAnalyzer(g); a.compute(); assertTrue(a.getDegreeEntropy() > 0); @@ -632,15 +632,15 @@ public void testStarHigherDegreeEntropyThanCycle() { @Test public void testEdgeTypeEntropyMonotonicity() { - Graph g1 = new UndirectedSparseGraph<>(); + Graph g1 = new UndirectedSparseGraph<>(); g1.addVertex("A"); g1.addVertex("B"); g1.addVertex("C"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1); g1.addEdge(e1, "A", "B"); - edge e2 = new edge("f", "B", "C"); e2.setWeight(1); g1.addEdge(e2, "B", "C"); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1); g1.addEdge(e1, "A", "B"); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(1); g1.addEdge(e2, "B", "C"); - Graph g2 = new UndirectedSparseGraph<>(); + Graph g2 = new UndirectedSparseGraph<>(); g2.addVertex("A"); g2.addVertex("B"); g2.addVertex("C"); - edge e3 = new edge("f", "A", "B"); e3.setWeight(1); g2.addEdge(e3, "A", "B"); - edge e4 = new edge("c", "B", "C"); e4.setWeight(1); g2.addEdge(e4, "B", "C"); + edge e3 = new Edge("f", "A", "B"); e3.setWeight(1); g2.addEdge(e3, "A", "B"); + edge e4 = new Edge("c", "B", "C"); e4.setWeight(1); g2.addEdge(e4, "B", "C"); GraphEntropyAnalyzer a1 = new GraphEntropyAnalyzer(g1); a1.compute(); @@ -692,13 +692,13 @@ public void testWheelGraph() { graph.addVertex("C"); for (int i = 1; i <= 6; i++) { graph.addVertex("N" + i); - edge e = new edge("f", "C", "N" + i); + edge e = new Edge("f", "C", "N" + i); e.setWeight(1.0f); graph.addEdge(e, "C", "N" + i); } for (int i = 1; i <= 6; i++) { int next = (i % 6) + 1; - edge e = new edge("f", "N" + i, "N" + next); + edge e = new Edge("f", "N" + i, "N" + next); e.setWeight(1.0f); graph.addEdge(e, "N" + i, "N" + next); } diff --git a/Gvisual/test/gvisual/GraphGeneratorTest.java b/Gvisual/test/gvisual/GraphGeneratorTest.java index b078be4..3b3ec1d 100644 --- a/Gvisual/test/gvisual/GraphGeneratorTest.java +++ b/Gvisual/test/gvisual/GraphGeneratorTest.java @@ -64,7 +64,7 @@ public void complete_negativeNodes_throws() { @Test public void complete_allNodesConnected() { GraphGenerator.GeneratedGraph result = gen.complete(4); - Graph g = result.getGraph(); + Graph g = result.getGraph(); for (String v : g.getVertices()) { assertEquals(3, g.degree(v)); } @@ -110,7 +110,7 @@ public void star_tenNodes() { assertEquals(10, result.getNodeCount()); assertEquals(9, result.getEdgeCount()); // Hub has degree n-1, leaves have degree 1 - Graph g = result.getGraph(); + Graph g = result.getGraph(); assertEquals(9, g.degree("n0")); for (int i = 1; i < 10; i++) { assertEquals(1, g.degree("n" + i)); @@ -184,7 +184,7 @@ public void path_fiveNodes() { assertEquals(5, result.getNodeCount()); assertEquals(4, result.getEdgeCount()); // Endpoints have degree 1, interior nodes have degree 2 - Graph g = result.getGraph(); + Graph g = result.getGraph(); assertEquals(1, g.degree("n0")); assertEquals(2, g.degree("n2")); assertEquals(1, g.degree("n4")); @@ -314,7 +314,7 @@ public void scaleFreeBa_m1() { @Test public void scaleFreeBa_hasHubs() { GraphGenerator.GeneratedGraph result = gen.scaleFreeBa(100, 2); - Graph g = result.getGraph(); + Graph g = result.getGraph(); // Early nodes should have higher degree (preferential attachment) int maxDegree = 0; for (String v : g.getVertices()) { @@ -416,7 +416,7 @@ public void bipartite_pOne_complete() { @Test public void bipartite_noIntraGroupEdges() { GraphGenerator.GeneratedGraph result = gen.bipartite(5, 5, 1.0); - Graph g = result.getGraph(); + Graph g = result.getGraph(); // Group A: n0-n4, Group B: n5-n9 // No edges within group A for (int i = 0; i < 5; i++) { @@ -548,7 +548,7 @@ public void reproducibility_differentSeed_likelyDifferent() { @Test public void generatedGraphs_workWithExistingAnalyzers() { GraphGenerator.GeneratedGraph result = gen.scaleFreeBa(30, 2); - Graph g = result.getGraph(); + Graph g = result.getGraph(); // Should work with ShortestPathFinder ShortestPathFinder spf = new ShortestPathFinder(g); @@ -571,11 +571,11 @@ public void generatedGraphs_workWithExistingAnalyzers() { @Test public void generatedGraphs_workWithGraphStats() { GraphGenerator.GeneratedGraph result = gen.ring(10); - Graph g = result.getGraph(); + Graph g = result.getGraph(); // Build edge lists (all "f" type in generated graphs) - List allEdges = new ArrayList<>(g.getEdges()); - List empty = Collections.emptyList(); + List allEdges = new ArrayList<>(g.getEdges()); + List empty = Collections.emptyList(); GraphStats stats = new GraphStats(g, allEdges, empty, empty, empty, empty); assertEquals(10, stats.getNodeCount()); diff --git a/Gvisual/test/gvisual/GraphIsomorphismAnalyzerTest.java b/Gvisual/test/gvisual/GraphIsomorphismAnalyzerTest.java index 2064bb6..d93c8f9 100644 --- a/Gvisual/test/gvisual/GraphIsomorphismAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphIsomorphismAnalyzerTest.java @@ -19,13 +19,13 @@ public class GraphIsomorphismAnalyzerTest { * Build an undirected graph from edge pairs. * Each edge is [vertex1, vertex2]. */ - private Graph buildGraph(String[][] edges) { - Graph g = new UndirectedSparseGraph(); + private Graph buildGraph(String[][] edges) { + Graph g = new UndirectedSparseGraph(); int edgeId = 0; for (String[] e : edges) { if (!g.containsVertex(e[0])) g.addVertex(e[0]); if (!g.containsVertex(e[1])) g.addVertex(e[1]); - edge ed = new edge("c", e[0], e[1]); + edge ed = new Edge("c", e[0], e[1]); ed.setLabel("e" + edgeId++); g.addEdge(ed, e[0], e[1]); } @@ -35,8 +35,8 @@ private Graph buildGraph(String[][] edges) { /** * Build a graph with only isolated vertices. */ - private Graph buildIsolated(String... vertices) { - Graph g = new UndirectedSparseGraph(); + private Graph buildIsolated(String... vertices) { + Graph g = new UndirectedSparseGraph(); for (String v : vertices) g.addVertex(v); return g; } @@ -45,13 +45,13 @@ private Graph buildIsolated(String... vertices) { @Test(expected = IllegalArgumentException.class) public void constructor_nullGraph1_throws() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); new GraphIsomorphismAnalyzer(null, g); } @Test(expected = IllegalArgumentException.class) public void constructor_nullGraph2_throws() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); new GraphIsomorphismAnalyzer(g, null); } @@ -64,8 +64,8 @@ public void constructor_bothNull_throws() { @Test public void analyze_twoEmptyGraphs_isomorphic() { - Graph g1 = new UndirectedSparseGraph(); - Graph g2 = new UndirectedSparseGraph(); + Graph g1 = new UndirectedSparseGraph(); + Graph g2 = new UndirectedSparseGraph(); GraphIsomorphismAnalyzer analyzer = new GraphIsomorphismAnalyzer(g1, g2); GraphIsomorphismAnalyzer.IsomorphismResult result = analyzer.analyze(); @@ -79,8 +79,8 @@ public void analyze_twoEmptyGraphs_isomorphic() { @Test public void analyze_singleVertexEach_isomorphic() { - Graph g1 = buildIsolated("A"); - Graph g2 = buildIsolated("X"); + Graph g1 = buildIsolated("A"); + Graph g2 = buildIsolated("X"); GraphIsomorphismAnalyzer.IsomorphismResult result = new GraphIsomorphismAnalyzer(g1, g2).analyze(); @@ -94,10 +94,10 @@ public void analyze_singleVertexEach_isomorphic() { @Test public void analyze_identicalTriangles_isomorphic() { - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "A"} }); - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"X", "Y"}, {"Y", "Z"}, {"Z", "X"} }); @@ -113,11 +113,11 @@ public void analyze_identicalTriangles_isomorphic() { @Test public void analyze_identicalPaths_isomorphic() { // Path: A-B-C-D - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "D"} }); // Path: W-X-Y-Z - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"W", "X"}, {"X", "Y"}, {"Y", "Z"} }); @@ -131,11 +131,11 @@ public void analyze_identicalPaths_isomorphic() { @Test public void analyze_identicalStars_isomorphic() { // Star: center A connected to B, C, D, E - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"A", "C"}, {"A", "D"}, {"A", "E"} }); // Star: center M connected to N, O, P, Q - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"M", "N"}, {"M", "O"}, {"M", "P"}, {"M", "Q"} }); @@ -148,11 +148,11 @@ public void analyze_identicalStars_isomorphic() { @Test public void analyze_completeK4_isomorphic() { - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"A", "C"}, {"A", "D"}, {"B", "C"}, {"B", "D"}, {"C", "D"} }); - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"W", "X"}, {"W", "Y"}, {"W", "Z"}, {"X", "Y"}, {"X", "Z"}, {"Y", "Z"} }); @@ -168,10 +168,10 @@ public void analyze_completeK4_isomorphic() { @Test public void analyze_differentVertexCount_notIsomorphic() { - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"B", "C"} }); - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"X", "Y"}, {"Y", "Z"}, {"Z", "W"} }); @@ -185,17 +185,17 @@ public void analyze_differentVertexCount_notIsomorphic() { @Test public void analyze_differentEdgeCount_notIsomorphic() { // Triangle vs path of 3 - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "A"} }); - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"X", "Y"}, {"Y", "Z"} }); g2.addVertex("W"); // add isolated vertex to match vertex count // g1: 3 vertices 3 edges, g2: 4 vertices 2 edges → vertex count diff // Let's make same vertex count - Graph g2b = buildGraph(new String[][]{ + Graph g2b = buildGraph(new String[][]{ {"X", "Y"}, {"Y", "Z"} }); // g1: 3v 3e, g2b: 3v 2e @@ -210,11 +210,11 @@ public void analyze_differentEdgeCount_notIsomorphic() { @Test public void analyze_differentDegreeSequence_notIsomorphic() { // Star: center A → B, C, D (degrees: 3,1,1,1) - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"A", "C"}, {"A", "D"} }); // Path: X-Y-Z-W (degrees: 1,2,2,1) - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"X", "Y"}, {"Y", "Z"}, {"Z", "W"} }); @@ -229,12 +229,12 @@ public void analyze_differentDegreeSequence_notIsomorphic() { public void analyze_sameDegreeSequence_butNotIsomorphic() { // Two graphs with degree sequence [2,2,2,2,2,2] but different structure // Cycle C6: A-B-C-D-E-F-A - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "E"}, {"E", "F"}, {"F", "A"} }); // Two triangles: X-Y-Z-X and P-Q-R-P - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"X", "Y"}, {"Y", "Z"}, {"Z", "X"}, {"P", "Q"}, {"Q", "R"}, {"R", "P"} }); @@ -251,8 +251,8 @@ public void analyze_sameDegreeSequence_butNotIsomorphic() { @Test public void analyze_isolatedVertices_isomorphic() { - Graph g1 = buildIsolated("A", "B", "C"); - Graph g2 = buildIsolated("X", "Y", "Z"); + Graph g1 = buildIsolated("A", "B", "C"); + Graph g2 = buildIsolated("X", "Y", "Z"); GraphIsomorphismAnalyzer.IsomorphismResult result = new GraphIsomorphismAnalyzer(g1, g2).analyze(); @@ -263,8 +263,8 @@ public void analyze_isolatedVertices_isomorphic() { @Test public void analyze_differentIsolatedCount_notIsomorphic() { - Graph g1 = buildIsolated("A", "B"); - Graph g2 = buildIsolated("X", "Y", "Z"); + Graph g1 = buildIsolated("A", "B"); + Graph g2 = buildIsolated("X", "Y", "Z"); GraphIsomorphismAnalyzer.IsomorphismResult result = new GraphIsomorphismAnalyzer(g1, g2).analyze(); @@ -276,10 +276,10 @@ public void analyze_differentIsolatedCount_notIsomorphic() { @Test public void areIsomorphic_returns_true_for_matching_graphs() { - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"B", "C"} }); - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"X", "Y"}, {"Y", "Z"} }); @@ -288,10 +288,10 @@ public void areIsomorphic_returns_true_for_matching_graphs() { @Test public void areIsomorphic_returns_false_for_nonMatching() { - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "A"} }); - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"X", "Y"}, {"Y", "Z"} }); g2.addVertex("W"); @@ -303,10 +303,10 @@ public void areIsomorphic_returns_false_for_nonMatching() { @Test public void analyze_degreeSequencesReturned() { - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "B"}, {"A", "C"} }); - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"X", "Y"}, {"X", "Z"} }); @@ -323,12 +323,12 @@ public void analyze_degreeSequencesReturned() { public void analyze_petersenLike_isomorphic() { // Build two copies of the Petersen graph with different labels // Outer cycle: 0-1-2-3-4-0, inner star: 5-7-9-6-8-5 - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"0", "1"}, {"1", "2"}, {"2", "3"}, {"3", "4"}, {"4", "0"}, {"0", "5"}, {"1", "6"}, {"2", "7"}, {"3", "8"}, {"4", "9"}, {"5", "7"}, {"7", "9"}, {"9", "6"}, {"6", "8"}, {"8", "5"} }); - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "E"}, {"E", "A"}, {"A", "F"}, {"B", "G"}, {"C", "H"}, {"D", "I"}, {"E", "J"}, {"F", "H"}, {"H", "J"}, {"J", "G"}, {"G", "I"}, {"I", "F"} @@ -345,12 +345,12 @@ public void analyze_petersenLike_isomorphic() { @Test public void analyze_bipartiteK23_isomorphic() { // K2,3: {A,B} fully connected to {C,D,E} - Graph g1 = buildGraph(new String[][]{ + Graph g1 = buildGraph(new String[][]{ {"A", "C"}, {"A", "D"}, {"A", "E"}, {"B", "C"}, {"B", "D"}, {"B", "E"} }); // Same with different labels - Graph g2 = buildGraph(new String[][]{ + Graph g2 = buildGraph(new String[][]{ {"P", "R"}, {"P", "S"}, {"P", "T"}, {"Q", "R"}, {"Q", "S"}, {"Q", "T"} }); @@ -362,8 +362,8 @@ public void analyze_bipartiteK23_isomorphic() { @Test public void toString_isomorphic_showsMapping() { - Graph g1 = buildIsolated("A"); - Graph g2 = buildIsolated("X"); + Graph g1 = buildIsolated("A"); + Graph g2 = buildIsolated("X"); GraphIsomorphismAnalyzer.IsomorphismResult result = new GraphIsomorphismAnalyzer(g1, g2).analyze(); @@ -374,8 +374,8 @@ public void toString_isomorphic_showsMapping() { @Test public void toString_notIsomorphic_showsReason() { - Graph g1 = buildIsolated("A", "B"); - Graph g2 = buildIsolated("X"); + Graph g1 = buildIsolated("A", "B"); + Graph g2 = buildIsolated("X"); GraphIsomorphismAnalyzer.IsomorphismResult result = new GraphIsomorphismAnalyzer(g1, g2).analyze(); @@ -388,10 +388,10 @@ public void toString_notIsomorphic_showsReason() { @Test public void analyze_graphWithIsolatedAndConnected_isomorphic() { // Graph: A-B, C isolated - Graph g1 = buildGraph(new String[][]{{"A", "B"}}); + Graph g1 = buildGraph(new String[][]{{"A", "B"}}); g1.addVertex("C"); - Graph g2 = buildGraph(new String[][]{{"X", "Y"}}); + Graph g2 = buildGraph(new String[][]{{"X", "Y"}}); g2.addVertex("Z"); assertTrue(new GraphIsomorphismAnalyzer(g1, g2).areIsomorphic()); @@ -399,7 +399,7 @@ public void analyze_graphWithIsolatedAndConnected_isomorphic() { @Test public void analyze_selfIsomorphic() { - Graph g = buildGraph(new String[][]{ + Graph g = buildGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "A"} }); @@ -410,8 +410,8 @@ public void analyze_selfIsomorphic() { @Test(expected = UnsupportedOperationException.class) public void mapping_isUnmodifiable() { - Graph g1 = buildIsolated("A"); - Graph g2 = buildIsolated("X"); + Graph g1 = buildIsolated("A"); + Graph g2 = buildIsolated("X"); GraphIsomorphismAnalyzer.IsomorphismResult result = new GraphIsomorphismAnalyzer(g1, g2).analyze(); result.getMapping().put("B", "Y"); @@ -419,8 +419,8 @@ public void mapping_isUnmodifiable() { @Test(expected = UnsupportedOperationException.class) public void degreeSequence_isUnmodifiable() { - Graph g1 = buildIsolated("A"); - Graph g2 = buildIsolated("X"); + Graph g1 = buildIsolated("A"); + Graph g2 = buildIsolated("X"); GraphIsomorphismAnalyzer.IsomorphismResult result = new GraphIsomorphismAnalyzer(g1, g2).analyze(); result.getDegreeSequence1().add(42); @@ -433,10 +433,10 @@ public void degreeSequence_isUnmodifiable() { * for every edge (u, v) in g1, (mapping[u], mapping[v]) must be * an edge in g2. */ - private void verifyMapping(Graph g1, - Graph g2, + private void verifyMapping(Graph g1, + Graph g2, Map mapping) { - for (edge e : g1.getEdges()) { + for (Edge e : g1.getEdges()) { String u1 = e.getVertex1(); String v1 = e.getVertex2(); // JUNG undirected edges might have endpoints in either order diff --git a/Gvisual/test/gvisual/GraphMLExporterTest.java b/Gvisual/test/gvisual/GraphMLExporterTest.java index 3ea7238..5eaddfb 100644 --- a/Gvisual/test/gvisual/GraphMLExporterTest.java +++ b/Gvisual/test/gvisual/GraphMLExporterTest.java @@ -24,13 +24,13 @@ public class GraphMLExporterTest { @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); - private Graph graph; - private List allEdges; + private Graph graph; + private List allEdges; @Before public void setUp() { - graph = new UndirectedSparseGraph(); - allEdges = new ArrayList(); + graph = new UndirectedSparseGraph(); + allEdges = new ArrayList(); } // --- Constructor tests --- @@ -98,7 +98,7 @@ public void testVerticesSortedDeterministic() { @Test public void testEdgesExported() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(42.5f); allEdges.add(e); graph.addEdge(e, "A", "B"); @@ -114,7 +114,7 @@ public void testEdgesExported() { @Test public void testEdgeLabelExported() { - edge e = new edge("c", "X", "Y"); + edge e = new Edge("c", "X", "Y"); e.setWeight(10f); e.setLabel("Classmate"); allEdges.add(e); @@ -128,7 +128,7 @@ public void testEdgeLabelExported() { @Test public void testEdgeWithoutLabelOmitted() { - edge e = new edge("s", "X", "Y"); + edge e = new Edge("s", "X", "Y"); e.setWeight(5f); allEdges.add(e); graph.addEdge(e, "X", "Y"); @@ -154,11 +154,11 @@ public void testAllEdgeTypeLabels() { @Test public void testMultipleEdgeTypesExported() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(10f); - edge e2 = new edge("fs", "B", "C"); e2.setWeight(5f); - edge e3 = new edge("c", "C", "D"); e3.setWeight(20f); - edge e4 = new edge("s", "D", "E"); e4.setWeight(3f); - edge e5 = new edge("sg", "E", "A"); e5.setWeight(15f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(10f); + edge e2 = new Edge("fs", "B", "C"); e2.setWeight(5f); + edge e3 = new Edge("c", "C", "D"); e3.setWeight(20f); + edge e4 = new Edge("s", "D", "E"); e4.setWeight(3f); + edge e5 = new Edge("sg", "E", "A"); e5.setWeight(15f); allEdges.add(e1); allEdges.add(e2); allEdges.add(e3); allEdges.add(e4); allEdges.add(e5); graph.addEdge(e1, "A", "B"); @@ -266,7 +266,7 @@ public void testVertexWithSpecialCharsEscaped() { @Test public void testExportToFile() throws IOException { - edge e = new edge("f", "X", "Y"); + edge e = new Edge("f", "X", "Y"); e.setWeight(99f); allEdges.add(e); graph.addEdge(e, "X", "Y"); @@ -302,8 +302,8 @@ public void testVertexCount() { @Test public void testEdgeCountUsesAllEdges() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(10f); - edge e2 = new edge("c", "C", "D"); e2.setWeight(20f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(10f); + edge e2 = new Edge("c", "C", "D"); e2.setWeight(20f); allEdges.add(e1); allEdges.add(e2); // Only add one to graph (simulating filter) @@ -317,10 +317,10 @@ public void testEdgeCountUsesAllEdges() { @Test public void testEdgeCountFallsBackToGraphEdges() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(10f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(10f); graph.addEdge(e1, "A", "B"); - GraphMLExporter exporter = new GraphMLExporter(graph, new ArrayList()); + GraphMLExporter exporter = new GraphMLExporter(graph, new ArrayList()); assertEquals(1, exporter.getEdgeCount()); } @@ -345,8 +345,8 @@ public void testKeyDefinitionsPresent() { @Test public void testExportVisibleOnly() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(10f); - edge e2 = new edge("c", "C", "D"); e2.setWeight(20f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(10f); + edge e2 = new Edge("c", "C", "D"); e2.setWeight(20f); allEdges.add(e1); allEdges.add(e2); // Only e1 in graph @@ -378,7 +378,7 @@ public void testLargeGraphExport() { graph.addVertex("N" + i); } for (int i = 0; i < 99; i++) { - edge e = new edge("f", "N" + i, "N" + (i + 1)); + edge e = new Edge("f", "N" + i, "N" + (i + 1)); e.setWeight(i * 1.5f); allEdges.add(e); graph.addEdge(e, "N" + i, "N" + (i + 1)); @@ -399,7 +399,7 @@ public void testLargeGraphExport() { @Test public void testEdgeWeightFormatting() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(3.14159f); allEdges.add(e); graph.addEdge(e, "A", "B"); @@ -413,7 +413,7 @@ public void testEdgeWeightFormatting() { @Test public void testZeroWeightEdge() { - edge e = new edge("s", "A", "B"); + edge e = new Edge("s", "A", "B"); e.setWeight(0f); allEdges.add(e); graph.addEdge(e, "A", "B"); @@ -448,7 +448,7 @@ public void testGraphIdAndEdgeDefault() { @Test public void testEdgeWithEmptyLabelOmitted() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(10f); e.setLabel(""); allEdges.add(e); @@ -465,7 +465,7 @@ public void testEdgeWithEmptyLabelOmitted() { @Test public void testIsolatedVerticesExported() { graph.addVertex("Lonely"); - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(10f); allEdges.add(e); graph.addEdge(e, "A", "B"); @@ -481,7 +481,7 @@ public void testIsolatedVerticesExported() { @Test public void testDeterministicOutput() { - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(10f); allEdges.add(e); graph.addEdge(e, "A", "B"); @@ -546,7 +546,7 @@ public void testEscapeXml_mixedControlAndSpecial() { public void testExport_vertexWithControlCharsProducesValidXml() { graph.addVertex("node\0inject"); graph.addVertex("B"); - edge e = new edge("f", "node\0inject", "B"); + edge e = new Edge("f", "node\0inject", "B"); allEdges.add(e); graph.addEdge(e, "node\0inject", "B"); diff --git a/Gvisual/test/gvisual/GraphMergerTest.java b/Gvisual/test/gvisual/GraphMergerTest.java index bea64d3..4e6e4d4 100644 --- a/Gvisual/test/gvisual/GraphMergerTest.java +++ b/Gvisual/test/gvisual/GraphMergerTest.java @@ -17,8 +17,8 @@ */ public class GraphMergerTest { - private Graph graphA; - private Graph graphB; + private Graph graphA; + private Graph graphB; @Before public void setUp() { @@ -27,9 +27,9 @@ public void setUp() { graphA.addVertex("A"); graphA.addVertex("B"); graphA.addVertex("C"); - edge ab = new edge("undirected", "A", "B"); + edge ab = new Edge("undirected", "A", "B"); ab.setWeight(1.0f); - edge bc = new edge("undirected", "B", "C"); + edge bc = new Edge("undirected", "B", "C"); bc.setWeight(1.0f); graphA.addEdge(ab, "A", "B"); graphA.addEdge(bc, "B", "C"); @@ -39,9 +39,9 @@ public void setUp() { graphB.addVertex("B"); graphB.addVertex("C"); graphB.addVertex("D"); - edge bc2 = new edge("undirected", "B", "C"); + edge bc2 = new Edge("undirected", "B", "C"); bc2.setWeight(3.0f); - edge cd = new edge("undirected", "C", "D"); + edge cd = new Edge("undirected", "C", "D"); cd.setWeight(2.0f); graphB.addEdge(bc2, "B", "C"); graphB.addEdge(cd, "C", "D"); @@ -58,7 +58,7 @@ public void testUnionMerge() { assertEquals(3, result.getMergedEdgeCount()); // A-B, B-C, C-D assertEquals(1, result.getConflictsResolved()); // B-C conflict - Graph merged = result.getMergedGraph(); + Graph merged = result.getMergedGraph(); assertTrue(merged.containsVertex("A")); assertTrue(merged.containsVertex("D")); } @@ -134,7 +134,7 @@ public void testIntersectionMerge() { assertEquals(2, result.getMergedVertexCount()); assertEquals(1, result.getMergedEdgeCount()); - Graph merged = result.getMergedGraph(); + Graph merged = result.getMergedGraph(); assertTrue(merged.containsVertex("B")); assertTrue(merged.containsVertex("C")); assertFalse(merged.containsVertex("A")); @@ -152,7 +152,7 @@ public void testSymmetricDifferenceMerge() { // B-C is in both → excluded. assertEquals(2, result.getMergedEdgeCount()); // A-B, C-D - Graph merged = result.getMergedGraph(); + Graph merged = result.getMergedGraph(); assertTrue(merged.containsVertex("A")); assertTrue(merged.containsVertex("D")); } @@ -230,8 +230,8 @@ public void testSharedVertices() { @Test public void testMergeEmptyGraphs() { - Graph empty1 = new UndirectedSparseGraph<>(); - Graph empty2 = new UndirectedSparseGraph<>(); + Graph empty1 = new UndirectedSparseGraph<>(); + Graph empty2 = new UndirectedSparseGraph<>(); GraphMerger.MergeResult result = GraphMerger.merge(empty1, empty2); assertEquals(0, result.getMergedVertexCount()); diff --git a/Gvisual/test/gvisual/GraphMinorAnalyzerTest.java b/Gvisual/test/gvisual/GraphMinorAnalyzerTest.java index 3c5534e..0424efb 100644 --- a/Gvisual/test/gvisual/GraphMinorAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphMinorAnalyzerTest.java @@ -14,58 +14,58 @@ public class GraphMinorAnalyzerTest { // ── Helpers ───────────────────────────────────────────────────────── - private Graph makePath(int n) { - Graph g = new UndirectedSparseGraph<>(); + private Graph makePath(int n) { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < n; i++) g.addVertex("v" + i); for (int i = 0; i < n - 1; i++) - g.addEdge(new edge("e" + i, "v" + i, "v" + (i + 1)), "v" + i, "v" + (i + 1)); + g.addEdge(new Edge("e" + i, "v" + i, "v" + (i + 1)), "v" + i, "v" + (i + 1)); return g; } - private Graph makeCycle(int n) { - Graph g = makePath(n); - g.addEdge(new edge("ec", "v" + (n - 1), "v0"), "v" + (n - 1), "v0"); + private Graph makeCycle(int n) { + Graph g = makePath(n); + g.addEdge(new Edge("ec", "v" + (n - 1), "v0"), "v" + (n - 1), "v0"); return g; } - private Graph makeComplete(int n) { - Graph g = new UndirectedSparseGraph<>(); + private Graph makeComplete(int n) { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < n; i++) g.addVertex("v" + i); int id = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) - g.addEdge(new edge("e" + id++, "v" + i, "v" + j), "v" + i, "v" + j); + g.addEdge(new Edge("e" + id++, "v" + i, "v" + j), "v" + i, "v" + j); return g; } - private Graph makeK33() { - Graph g = new UndirectedSparseGraph<>(); + private Graph makeK33() { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < 3; i++) { g.addVertex("a" + i); g.addVertex("b" + i); } int id = 0; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) - g.addEdge(new edge("e" + id++, "a" + i, "b" + j), "a" + i, "b" + j); + g.addEdge(new Edge("e" + id++, "a" + i, "b" + j), "a" + i, "b" + j); return g; } - private Graph makeEmpty(int n) { - Graph g = new UndirectedSparseGraph<>(); + private Graph makeEmpty(int n) { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < n; i++) g.addVertex("v" + i); return g; } - private Graph makePetersen() { - Graph g = new UndirectedSparseGraph<>(); + private Graph makePetersen() { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < 10; i++) g.addVertex("v" + i); // Outer cycle for (int i = 0; i < 5; i++) - g.addEdge(new edge("o" + i, "v" + i, "v" + ((i + 1) % 5)), "v" + i, "v" + ((i + 1) % 5)); + g.addEdge(new Edge("o" + i, "v" + i, "v" + ((i + 1) % 5)), "v" + i, "v" + ((i + 1) % 5)); // Inner pentagram for (int i = 0; i < 5; i++) - g.addEdge(new edge("i" + i, "v" + (i + 5), "v" + ((i + 2) % 5 + 5)), "v" + (i + 5), "v" + ((i + 2) % 5 + 5)); + g.addEdge(new Edge("i" + i, "v" + (i + 5), "v" + ((i + 2) % 5 + 5)), "v" + (i + 5), "v" + ((i + 2) % 5 + 5)); // Spokes for (int i = 0; i < 5; i++) - g.addEdge(new edge("s" + i, "v" + i, "v" + (i + 5)), "v" + i, "v" + (i + 5)); + g.addEdge(new Edge("s" + i, "v" + i, "v" + (i + 5)), "v" + i, "v" + (i + 5)); return g; } @@ -80,16 +80,16 @@ public void testNullGraph() { @Test public void testCopyPreservesStructure() { - Graph g = makeComplete(4); - Graph copy = GraphMinorAnalyzer.copyGraph(g); + Graph g = makeComplete(4); + Graph copy = GraphMinorAnalyzer.copyGraph(g); assertEquals(g.getVertexCount(), copy.getVertexCount()); assertEquals(g.getEdgeCount(), copy.getEdgeCount()); } @Test public void testCopyIsIndependent() { - Graph g = makeComplete(3); - Graph copy = GraphMinorAnalyzer.copyGraph(g); + Graph g = makeComplete(3); + Graph copy = GraphMinorAnalyzer.copyGraph(g); copy.removeVertex("v0"); assertEquals(3, g.getVertexCount()); assertEquals(2, copy.getVertexCount()); @@ -100,7 +100,7 @@ public void testCopyIsIndependent() { @Test public void testDeleteVertex() { GraphMinorAnalyzer a = new GraphMinorAnalyzer(makeComplete(4)); - Graph result = a.deleteVertex("v0"); + Graph result = a.deleteVertex("v0"); assertEquals(3, result.getVertexCount()); assertFalse(result.containsVertex("v0")); // K4 - v0 = K3 @@ -115,7 +115,7 @@ public void testDeleteVertexNotFound() { @Test public void testDeleteMultipleVertices() { GraphMinorAnalyzer a = new GraphMinorAnalyzer(makeComplete(5)); - Graph result = a.deleteVertices(Arrays.asList("v0", "v1")); + Graph result = a.deleteVertices(Arrays.asList("v0", "v1")); assertEquals(3, result.getVertexCount()); assertEquals(3, result.getEdgeCount()); // K3 } @@ -125,7 +125,7 @@ public void testDeleteMultipleVertices() { @Test public void testDeleteEdge() { GraphMinorAnalyzer a = new GraphMinorAnalyzer(makeComplete(3)); - Graph result = a.deleteEdge("v0", "v1"); + Graph result = a.deleteEdge("v0", "v1"); assertEquals(3, result.getVertexCount()); assertEquals(2, result.getEdgeCount()); assertNull(result.findEdge("v0", "v1")); @@ -142,7 +142,7 @@ public void testDeleteEdgeNotFound() { public void testContractEdgeReducesVertices() { GraphMinorAnalyzer a = new GraphMinorAnalyzer(makePath(3)); // v0--v1--v2, contract v0-v1 - Graph result = a.contractEdge("v0", "v1"); + Graph result = a.contractEdge("v0", "v1"); assertEquals(2, result.getVertexCount()); assertTrue(result.containsVertex("v0")); assertTrue(result.containsVertex("v2")); @@ -152,7 +152,7 @@ public void testContractEdgeReducesVertices() { @Test public void testContractEdgeInTriangle() { GraphMinorAnalyzer a = new GraphMinorAnalyzer(makeComplete(3)); - Graph result = a.contractEdge("v0", "v1"); + Graph result = a.contractEdge("v0", "v1"); // K3 contract → K2 (v0 and v2 with one edge) assertEquals(2, result.getVertexCount()); assertEquals(1, result.getEdgeCount()); @@ -161,7 +161,7 @@ public void testContractEdgeInTriangle() { @Test public void testContractEdgeK4ToK3() { GraphMinorAnalyzer a = new GraphMinorAnalyzer(makeComplete(4)); - Graph result = a.contractEdge("v0", "v1"); + Graph result = a.contractEdge("v0", "v1"); // K4 contract one edge → K3 assertEquals(3, result.getVertexCount()); assertEquals(3, result.getEdgeCount()); @@ -182,7 +182,7 @@ public void testMinorSequence() { GraphMinorAnalyzer.MinorOp.deleteVertex("v3"), GraphMinorAnalyzer.MinorOp.contract("v0", "v1") ); - Graph result = a.applySequence(ops); + Graph result = a.applySequence(ops); assertEquals(2, result.getVertexCount()); } @@ -297,7 +297,7 @@ public void testNoK33MinorInSmallGraph() { @Test public void testHadwigerEmpty() { - assertEquals(0, new GraphMinorAnalyzer(new UndirectedSparseGraph()).hadwigerNumber()); + assertEquals(0, new GraphMinorAnalyzer(new UndirectedSparseGraph()).hadwigerNumber()); } @Test @@ -331,16 +331,16 @@ public void testContractionDegeneracyConnected() { @Test public void testContractionDegeneracyDisconnected() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("a"); g.addVertex("b"); g.addVertex("c"); - g.addEdge(new edge("e0", "a", "b"), "a", "b"); + g.addEdge(new Edge("e0", "a", "b"), "a", "b"); // c is isolated → 2 components assertEquals(2, new GraphMinorAnalyzer(g).contractionDegeneracy()); } @Test public void testContractionDegeneracyEmpty() { - assertEquals(0, new GraphMinorAnalyzer(new UndirectedSparseGraph()).contractionDegeneracy()); + assertEquals(0, new GraphMinorAnalyzer(new UndirectedSparseGraph()).contractionDegeneracy()); } // ── Subdivide edge ────────────────────────────────────────────────── @@ -348,7 +348,7 @@ public void testContractionDegeneracyEmpty() { @Test public void testSubdivideEdge() { GraphMinorAnalyzer a = new GraphMinorAnalyzer(makePath(2)); - Graph result = a.subdivideEdge("v0", "v1", "mid"); + Graph result = a.subdivideEdge("v0", "v1", "mid"); assertEquals(3, result.getVertexCount()); assertEquals(2, result.getEdgeCount()); assertNull(result.findEdge("v0", "v1")); diff --git a/Gvisual/test/gvisual/GraphNeighborhoodAnalyzerTest.java b/Gvisual/test/gvisual/GraphNeighborhoodAnalyzerTest.java index 2bc66d2..7036e3f 100644 --- a/Gvisual/test/gvisual/GraphNeighborhoodAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphNeighborhoodAnalyzerTest.java @@ -14,7 +14,7 @@ */ public class GraphNeighborhoodAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -22,7 +22,7 @@ public void setUp() { } private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/GraphNetworkProfilerTest.java b/Gvisual/test/gvisual/GraphNetworkProfilerTest.java index 97b76ca..9b97946 100644 --- a/Gvisual/test/gvisual/GraphNetworkProfilerTest.java +++ b/Gvisual/test/gvisual/GraphNetworkProfilerTest.java @@ -17,20 +17,20 @@ public class GraphNetworkProfilerTest { // ── Helpers ───────────────────────────────────────────────── - private static Graph emptyGraph() { + private static Graph emptyGraph() { return new UndirectedSparseGraph<>(); } private static int edgeCounter = 0; - private static void addEdge(Graph g, String v1, String v2) { - edge e = new edge("f", v1, v2); + private static void addEdge(Graph g, String v1, String v2) { + edge e = new Edge("f", v1, v2); e.setLabel("e" + (edgeCounter++)); g.addEdge(e, v1, v2); } - private static Graph completeGraph(int n) { - Graph g = emptyGraph(); + private static Graph completeGraph(int n) { + Graph g = emptyGraph(); for (int i = 0; i < n; i++) g.addVertex("v" + i); for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) @@ -38,8 +38,8 @@ private static Graph completeGraph(int n) { return g; } - private static Graph starGraph(int spokes) { - Graph g = emptyGraph(); + private static Graph starGraph(int spokes) { + Graph g = emptyGraph(); g.addVertex("hub"); for (int i = 0; i < spokes; i++) { String s = "s" + i; @@ -48,21 +48,21 @@ private static Graph starGraph(int spokes) { return g; } - private static Graph pathGraph(int n) { - Graph g = emptyGraph(); + private static Graph pathGraph(int n) { + Graph g = emptyGraph(); for (int i = 0; i < n; i++) g.addVertex("v" + i); for (int i = 0; i < n - 1; i++) addEdge(g, "v" + i, "v" + (i + 1)); return g; } - private static Graph ringGraph(int n) { - Graph g = pathGraph(n); + private static Graph ringGraph(int n) { + Graph g = pathGraph(n); addEdge(g, "v0", "v" + (n - 1)); return g; } - private static Graph gridGraph(int rows, int cols) { - Graph g = emptyGraph(); + private static Graph gridGraph(int rows, int cols) { + Graph g = emptyGraph(); for (int r = 0; r < rows; r++) for (int c = 0; c < cols; c++) g.addVertex(r + "," + c); @@ -87,7 +87,7 @@ public void testEmptyGraph() { @Test public void testSingleVertex() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("a"); GraphNetworkProfiler p = new GraphNetworkProfiler(g); p.analyze(); @@ -98,7 +98,7 @@ public void testSingleVertex() { @Test public void testTwoConnectedVertices() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); addEdge(g, "a", "b"); GraphNetworkProfiler p = new GraphNetworkProfiler(g); p.analyze(); @@ -182,7 +182,7 @@ public void testGridGraph() { @Test public void testDisconnectedGraph() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); addEdge(g, "a", "b"); addEdge(g, "c", "d"); g.addVertex("e"); // isolate @@ -369,7 +369,7 @@ public void testSmallWorldQuotientNonNegative() { @Test public void testLargeGraph() { // BA-style: start with K3, attach new nodes - Graph g = emptyGraph(); + Graph g = emptyGraph(); addEdge(g, "v0", "v1"); addEdge(g, "v1", "v2"); addEdge(g, "v0", "v2"); @@ -396,7 +396,7 @@ public void testLargeGraph() { @Test public void testDeterministicWithSeed() { - Graph g = gridGraph(5, 5); + Graph g = gridGraph(5, 5); GraphNetworkProfiler p1 = new GraphNetworkProfiler(g, new Random(42)); GraphNetworkProfiler p2 = new GraphNetworkProfiler(g, new Random(42)); p1.analyze(); @@ -428,7 +428,7 @@ public void testLargestComponentFractionSingle() { @Test public void testCorePeripheryShape() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); // Dense core of 5 nodes for (int i = 0; i < 5; i++) for (int j = i + 1; j < 5; j++) diff --git a/Gvisual/test/gvisual/GraphPartitionerTest.java b/Gvisual/test/gvisual/GraphPartitionerTest.java index aee49d0..8cedc23 100644 --- a/Gvisual/test/gvisual/GraphPartitionerTest.java +++ b/Gvisual/test/gvisual/GraphPartitionerTest.java @@ -14,7 +14,7 @@ */ public class GraphPartitionerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -24,7 +24,7 @@ public void setUp() { // ---- Helpers ---- private void addEdge(String u, String v) { - edge e = new edge("f", u, v); + edge e = new Edge("f", u, v); graph.addEdge(e, u, v); } diff --git a/Gvisual/test/gvisual/GraphPathExplorerTest.java b/Gvisual/test/gvisual/GraphPathExplorerTest.java index b49c6a3..765b7a1 100644 --- a/Gvisual/test/gvisual/GraphPathExplorerTest.java +++ b/Gvisual/test/gvisual/GraphPathExplorerTest.java @@ -16,7 +16,7 @@ */ public class GraphPathExplorerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -24,7 +24,7 @@ public void setUp() { } private edge makeEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); return e; } diff --git a/Gvisual/test/gvisual/GraphQueryEngineTest.java b/Gvisual/test/gvisual/GraphQueryEngineTest.java index bffce7e..8a2f09f 100644 --- a/Gvisual/test/gvisual/GraphQueryEngineTest.java +++ b/Gvisual/test/gvisual/GraphQueryEngineTest.java @@ -14,7 +14,7 @@ */ public class GraphQueryEngineTest { - private Graph graph; + private Graph graph; private GraphQueryEngine engine; @Before @@ -31,10 +31,10 @@ public void setUp() { graph.addVertex("D"); graph.addVertex("E"); - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("c", "B", "C"); e2.setWeight(2.5f); - edge e3 = new edge("f", "C", "D"); e3.setWeight(0.5f); - edge e4 = new edge("s", "B", "D"); e4.setWeight(3.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("c", "B", "C"); e2.setWeight(2.5f); + edge e3 = new Edge("f", "C", "D"); e3.setWeight(0.5f); + edge e4 = new Edge("s", "B", "D"); e4.setWeight(3.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -108,26 +108,26 @@ public void testEdgeOfType() { @Test public void testEdgeMinWeight() { - Set result = engine.edges().withMinWeight(2.0f).results(); + Set result = engine.edges().withMinWeight(2.0f).results(); assertEquals(2, result.size()); // c=2.5, s=3.0 } @Test public void testEdgeBetweenNodes() { Set subset = new HashSet<>(Arrays.asList("B", "C", "D")); - Set result = engine.edges().betweenNodes(subset).results(); + Set result = engine.edges().betweenNodes(subset).results(); assertEquals(3, result.size()); // B-C, C-D, B-D } @Test public void testEdgeIncidentTo() { - Set result = engine.edges().incidentTo("A").results(); + Set result = engine.edges().incidentTo("A").results(); assertEquals(1, result.size()); } @Test public void testEdgeSortedByWeight() { - List sorted = engine.edges().sortedByWeight(); + List sorted = engine.edges().sortedByWeight(); assertEquals(3.0f, sorted.get(0).getWeight(), 0.001f); } @@ -142,7 +142,7 @@ public void testEdgeTypeBreakdown() { @Test public void testChainedFilters() { // Edges of type "f" with weight >= 1.0 - Set result = engine.edges().ofType("f").withMinWeight(1.0f).results(); + Set result = engine.edges().ofType("f").withMinWeight(1.0f).results(); assertEquals(1, result.size()); // only A-B (w=1.0), C-D has w=0.5 } @@ -176,7 +176,7 @@ public void testEmptyResults() { @Test public void testTemporalEdgeQuery() { - edge te = new edge("f", "A", "E"); + edge te = new Edge("f", "A", "E"); te.setTimestamp(1000L); te.setEndTimestamp(2000L); graph.addEdge(te, "A", "E"); diff --git a/Gvisual/test/gvisual/GraphResilienceAnalyzerTest.java b/Gvisual/test/gvisual/GraphResilienceAnalyzerTest.java index 7253b32..8feb0f6 100644 --- a/Gvisual/test/gvisual/GraphResilienceAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphResilienceAnalyzerTest.java @@ -20,7 +20,7 @@ public class GraphResilienceAnalyzerTest { private int edgeCounter = 0; private edge makeEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setLabel("e" + (edgeCounter++)); return e; } @@ -28,8 +28,8 @@ private edge makeEdge(String v1, String v2) { /** * Creates a simple triangle graph: A—B—C—A. */ - private Graph createTriangle() { - Graph g = new UndirectedSparseGraph<>(); + private Graph createTriangle() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); @@ -42,8 +42,8 @@ private Graph createTriangle() { /** * Creates a star graph: center connected to N leaves. */ - private Graph createStar(int leaves) { - Graph g = new UndirectedSparseGraph<>(); + private Graph createStar(int leaves) { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("center"); for (int i = 0; i < leaves; i++) { String leaf = "leaf" + i; @@ -56,8 +56,8 @@ private Graph createStar(int leaves) { /** * Creates a path graph: v0—v1—v2—...—vN. */ - private Graph createPath(int length) { - Graph g = new UndirectedSparseGraph<>(); + private Graph createPath(int length) { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i <= length; i++) { g.addVertex("v" + i); } @@ -70,8 +70,8 @@ private Graph createPath(int length) { /** * Creates a complete graph K_n. */ - private Graph createComplete(int n) { - Graph g = new UndirectedSparseGraph<>(); + private Graph createComplete(int n) { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < n; i++) { g.addVertex("v" + i); } @@ -337,7 +337,7 @@ public void testGlobalEfficiency_DecreasesWithRemovals() { @Test public void testSingleNode_NoCrash() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("alone"); GraphResilienceAnalyzer analyzer = new GraphResilienceAnalyzer(g); @@ -351,7 +351,7 @@ public void testSingleNode_NoCrash() { @Test public void testTwoNodes_OneEdge() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addEdge(makeEdge("A", "B"), "A", "B"); @@ -369,7 +369,7 @@ public void testTwoNodes_OneEdge() { @Test public void testDisconnectedGraph() { // Two disconnected triangles - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addVertex("E"); g.addVertex("F"); g.addEdge(makeEdge("A", "B"), "A", "B"); diff --git a/Gvisual/test/gvisual/GraphSamplerTest.java b/Gvisual/test/gvisual/GraphSamplerTest.java index 4824f45..1388ef9 100644 --- a/Gvisual/test/gvisual/GraphSamplerTest.java +++ b/Gvisual/test/gvisual/GraphSamplerTest.java @@ -13,17 +13,17 @@ */ public class GraphSamplerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } private void addEdge(String v1, String v2) { graph.addVertex(v1); graph.addVertex(v2); - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); graph.addEdge(e, v1, v2); } diff --git a/Gvisual/test/gvisual/GraphSimilarityAnalyzerTest.java b/Gvisual/test/gvisual/GraphSimilarityAnalyzerTest.java index 99b60cb..81241e2 100644 --- a/Gvisual/test/gvisual/GraphSimilarityAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphSimilarityAnalyzerTest.java @@ -10,36 +10,36 @@ */ public class GraphSimilarityAnalyzerTest { - private Graph createTriangle() { - Graph g = new UndirectedSparseGraph<>(); + private Graph createTriangle() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - g.addEdge(new edge("friend", "A", "B"), "A", "B"); - g.addEdge(new edge("friend", "B", "C"), "B", "C"); - g.addEdge(new edge("friend", "A", "C"), "A", "C"); + g.addEdge(new Edge("friend", "A", "B"), "A", "B"); + g.addEdge(new Edge("friend", "B", "C"), "B", "C"); + g.addEdge(new Edge("friend", "A", "C"), "A", "C"); return g; } - private Graph createPath() { - Graph g = new UndirectedSparseGraph<>(); + private Graph createPath() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - g.addEdge(new edge("friend", "A", "B"), "A", "B"); - g.addEdge(new edge("friend", "B", "C"), "B", "C"); + g.addEdge(new Edge("friend", "A", "B"), "A", "B"); + g.addEdge(new Edge("friend", "B", "C"), "B", "C"); return g; } - private Graph createStar5() { - Graph g = new UndirectedSparseGraph<>(); + private Graph createStar5() { + Graph g = new UndirectedSparseGraph<>(); for (int i = 0; i < 5; i++) g.addVertex("V" + i); for (int i = 1; i < 5; i++) { - g.addEdge(new edge("friend", "V0", "V" + i), "V0", "V" + i); + g.addEdge(new Edge("friend", "V0", "V" + i), "V0", "V" + i); } return g; } @Test public void testIdenticalGraphs() { - Graph g1 = createTriangle(); - Graph g2 = createTriangle(); + Graph g1 = createTriangle(); + Graph g2 = createTriangle(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -52,8 +52,8 @@ public void testIdenticalGraphs() { @Test public void testDifferentGraphs() { - Graph g1 = createTriangle(); - Graph g2 = createStar5(); + Graph g1 = createTriangle(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -66,8 +66,8 @@ public void testDifferentGraphs() { @Test public void testJSDBounded() { - Graph g1 = createTriangle(); - Graph g2 = createPath(); + Graph g1 = createTriangle(); + Graph g2 = createPath(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -78,8 +78,8 @@ public void testJSDBounded() { @Test public void testVonNeumannNonNegative() { - Graph g1 = createPath(); - Graph g2 = createStar5(); + Graph g1 = createPath(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -89,8 +89,8 @@ public void testVonNeumannNonNegative() { @Test public void testEntropyProfiles() { - Graph g1 = createTriangle(); - Graph g2 = createStar5(); + Graph g1 = createTriangle(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -104,8 +104,8 @@ public void testEntropyProfiles() { @Test public void testEmptyGraphs() { - Graph g1 = new UndirectedSparseGraph<>(); - Graph g2 = new UndirectedSparseGraph<>(); + Graph g1 = new UndirectedSparseGraph<>(); + Graph g2 = new UndirectedSparseGraph<>(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -116,8 +116,8 @@ public void testEmptyGraphs() { @Test public void testReport() { - Graph g1 = createTriangle(); - Graph g2 = createStar5(); + Graph g1 = createTriangle(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -140,8 +140,8 @@ public void testNullGraph2() { @Test public void testSymmetry() { - Graph g1 = createTriangle(); - Graph g2 = createStar5(); + Graph g1 = createTriangle(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim12 = new GraphSimilarityAnalyzer(g1, g2); sim12.compute(); @@ -160,9 +160,9 @@ public void testSymmetry() { @Test public void testSingleVertexGraphs() { - Graph g1 = new UndirectedSparseGraph<>(); + Graph g1 = new UndirectedSparseGraph<>(); g1.addVertex("A"); - Graph g2 = new UndirectedSparseGraph<>(); + Graph g2 = new UndirectedSparseGraph<>(); g2.addVertex("X"); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); @@ -175,12 +175,12 @@ public void testSingleVertexGraphs() { @Test public void testSingleVertexVsEdge() { - Graph g1 = new UndirectedSparseGraph<>(); + Graph g1 = new UndirectedSparseGraph<>(); g1.addVertex("A"); - Graph g2 = new UndirectedSparseGraph<>(); + Graph g2 = new UndirectedSparseGraph<>(); g2.addVertex("A"); g2.addVertex("B"); - g2.addEdge(new edge("friend", "A", "B"), "A", "B"); + g2.addEdge(new Edge("friend", "A", "B"), "A", "B"); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -192,18 +192,18 @@ public void testSingleVertexVsEdge() { @Test public void testDisconnectedGraph() { // Two isolated components vs a connected graph - Graph disconnected = new UndirectedSparseGraph<>(); + Graph disconnected = new UndirectedSparseGraph<>(); disconnected.addVertex("A"); disconnected.addVertex("B"); disconnected.addVertex("C"); disconnected.addVertex("D"); - disconnected.addEdge(new edge("friend", "A", "B"), "A", "B"); - disconnected.addEdge(new edge("friend", "C", "D"), "C", "D"); + disconnected.addEdge(new Edge("friend", "A", "B"), "A", "B"); + disconnected.addEdge(new Edge("friend", "C", "D"), "C", "D"); - Graph connected = new UndirectedSparseGraph<>(); + Graph connected = new UndirectedSparseGraph<>(); connected.addVertex("A"); connected.addVertex("B"); connected.addVertex("C"); connected.addVertex("D"); - connected.addEdge(new edge("friend", "A", "B"), "A", "B"); - connected.addEdge(new edge("friend", "B", "C"), "B", "C"); - connected.addEdge(new edge("friend", "C", "D"), "C", "D"); + connected.addEdge(new Edge("friend", "A", "B"), "A", "B"); + connected.addEdge(new Edge("friend", "B", "C"), "B", "C"); + connected.addEdge(new Edge("friend", "C", "D"), "C", "D"); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(disconnected, connected); sim.compute(); @@ -216,8 +216,8 @@ public void testDisconnectedGraph() { @Test public void testDifferentSizedGraphs() { // Tests spectral padding: triangle (3 vertices) vs star5 (5 vertices) - Graph small = createTriangle(); - Graph large = createStar5(); + Graph small = createTriangle(); + Graph large = createStar5(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(small, large); sim.compute(); @@ -234,8 +234,8 @@ public void testDifferentSizedGraphs() { @Test public void testLazyCompute() { // Calling getters should trigger compute() automatically - Graph g1 = createTriangle(); - Graph g2 = createPath(); + Graph g1 = createTriangle(); + Graph g2 = createPath(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); // DO NOT call compute() — ensureComputed should handle it @@ -248,8 +248,8 @@ public void testLazyCompute() { @Test public void testComputeIdempotency() { - Graph g1 = createTriangle(); - Graph g2 = createStar5(); + Graph g1 = createTriangle(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -265,8 +265,8 @@ public void testComputeIdempotency() { @Test public void testProfilesCloned() { // getProfile1/getProfile2 should return defensive copies - Graph g1 = createTriangle(); - Graph g2 = createStar5(); + Graph g1 = createTriangle(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -286,7 +286,7 @@ public void testProfilesCloned() { @Test public void testSimilarityScoreBounds() { // Test across multiple graph pairs that similarity is always in [0, 1] - Graph[] graphs = new Graph[]{ + Graph[] graphs = new Graph[]{ createTriangle(), createPath(), createStar5(), new UndirectedSparseGraph<>() }; @@ -309,9 +309,9 @@ public void testSimilarityScoreBounds() { @Test public void testEntropyProfileDistanceTriangleInequality() { // For a metric: d(A,C) <= d(A,B) + d(B,C) - Graph a = createTriangle(); - Graph b = createPath(); - Graph c = createStar5(); + Graph a = createTriangle(); + Graph b = createPath(); + Graph c = createStar5(); GraphSimilarityAnalyzer ab = new GraphSimilarityAnalyzer(a, b); ab.compute(); @@ -327,8 +327,8 @@ public void testEntropyProfileDistanceTriangleInequality() { @Test public void testReportContainsGraphSizes() { - Graph g1 = createTriangle(); - Graph g2 = createStar5(); + Graph g1 = createTriangle(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -342,8 +342,8 @@ public void testReportContainsGraphSizes() { @Test public void testReportContainsInterpretation() { - Graph g1 = createTriangle(); - Graph g2 = createTriangle(); + Graph g1 = createTriangle(); + Graph g2 = createTriangle(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -358,8 +358,8 @@ public void testReportContainsInterpretation() { @Test public void testReportContainsEntropyProfileTable() { - Graph g1 = createTriangle(); - Graph g2 = createPath(); + Graph g1 = createTriangle(); + Graph g2 = createPath(); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -376,15 +376,15 @@ public void testReportContainsEntropyProfileTable() { @Test public void testCompleteGraphVsEmpty() { // Complete graph K4 vs graph with only isolated vertices - Graph complete = new UndirectedSparseGraph<>(); + Graph complete = new UndirectedSparseGraph<>(); for (int i = 0; i < 4; i++) complete.addVertex("V" + i); for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { - complete.addEdge(new edge("friend", "V" + i, "V" + j), "V" + i, "V" + j); + complete.addEdge(new Edge("friend", "V" + i, "V" + j), "V" + i, "V" + j); } } - Graph isolated = new UndirectedSparseGraph<>(); + Graph isolated = new UndirectedSparseGraph<>(); for (int i = 0; i < 4; i++) isolated.addVertex("V" + i); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(complete, isolated); @@ -400,17 +400,17 @@ public void testCompleteGraphVsEmpty() { @Test public void testIsomorphicGraphsDifferentLabels() { // Two triangles with different vertex labels should be identical - Graph g1 = new UndirectedSparseGraph<>(); + Graph g1 = new UndirectedSparseGraph<>(); g1.addVertex("A"); g1.addVertex("B"); g1.addVertex("C"); - g1.addEdge(new edge("friend", "A", "B"), "A", "B"); - g1.addEdge(new edge("friend", "B", "C"), "B", "C"); - g1.addEdge(new edge("friend", "A", "C"), "A", "C"); + g1.addEdge(new Edge("friend", "A", "B"), "A", "B"); + g1.addEdge(new Edge("friend", "B", "C"), "B", "C"); + g1.addEdge(new Edge("friend", "A", "C"), "A", "C"); - Graph g2 = new UndirectedSparseGraph<>(); + Graph g2 = new UndirectedSparseGraph<>(); g2.addVertex("X"); g2.addVertex("Y"); g2.addVertex("Z"); - g2.addEdge(new edge("friend", "X", "Y"), "X", "Y"); - g2.addEdge(new edge("friend", "Y", "Z"), "Y", "Z"); - g2.addEdge(new edge("friend", "X", "Z"), "X", "Z"); + g2.addEdge(new Edge("friend", "X", "Y"), "X", "Y"); + g2.addEdge(new Edge("friend", "Y", "Z"), "Y", "Z"); + g2.addEdge(new Edge("friend", "X", "Z"), "X", "Z"); GraphSimilarityAnalyzer sim = new GraphSimilarityAnalyzer(g1, g2); sim.compute(); @@ -423,8 +423,8 @@ public void testIsomorphicGraphsDifferentLabels() { @Test public void testVonNeumannSymmetry() { - Graph g1 = createPath(); - Graph g2 = createStar5(); + Graph g1 = createPath(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim12 = new GraphSimilarityAnalyzer(g1, g2); sim12.compute(); @@ -438,8 +438,8 @@ public void testVonNeumannSymmetry() { @Test public void testEntropyProfileDistanceSymmetry() { - Graph g1 = createTriangle(); - Graph g2 = createStar5(); + Graph g1 = createTriangle(); + Graph g2 = createStar5(); GraphSimilarityAnalyzer sim12 = new GraphSimilarityAnalyzer(g1, g2); sim12.compute(); diff --git a/Gvisual/test/gvisual/GraphSparsificationAnalyzerTest.java b/Gvisual/test/gvisual/GraphSparsificationAnalyzerTest.java index bf70e81..363fdae 100644 --- a/Gvisual/test/gvisual/GraphSparsificationAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphSparsificationAnalyzerTest.java @@ -9,55 +9,55 @@ public class GraphSparsificationAnalyzerTest { - private Graph triangle, path, star, complete5, disconnected, single, empty, weighted; + private Graph triangle, path, star, complete5, disconnected, single, empty, weighted; @Before public void setUp() { - triangle = new UndirectedSparseGraph(); + triangle = new UndirectedSparseGraph(); triangle.addVertex("A"); triangle.addVertex("B"); triangle.addVertex("C"); - triangle.addEdge(new edge("f", "A", "B"), "A", "B"); - triangle.addEdge(new edge("f", "B", "C"), "B", "C"); - triangle.addEdge(new edge("f", "A", "C"), "A", "C"); + triangle.addEdge(new Edge("f", "A", "B"), "A", "B"); + triangle.addEdge(new Edge("f", "B", "C"), "B", "C"); + triangle.addEdge(new Edge("f", "A", "C"), "A", "C"); - path = new UndirectedSparseGraph(); + path = new UndirectedSparseGraph(); for (String v : new String[]{"A","B","C","D"}) path.addVertex(v); - path.addEdge(new edge("f","A","B"),"A","B"); - path.addEdge(new edge("f","B","C"),"B","C"); - path.addEdge(new edge("f","C","D"),"C","D"); + path.addEdge(new Edge("f","A","B"),"A","B"); + path.addEdge(new Edge("f","B","C"),"B","C"); + path.addEdge(new Edge("f","C","D"),"C","D"); - star = new UndirectedSparseGraph(); + star = new UndirectedSparseGraph(); for (String v : new String[]{"A","B","C","D","E"}) star.addVertex(v); - star.addEdge(new edge("f","A","B"),"A","B"); - star.addEdge(new edge("f","A","C"),"A","C"); - star.addEdge(new edge("f","A","D"),"A","D"); - star.addEdge(new edge("f","A","E"),"A","E"); + star.addEdge(new Edge("f","A","B"),"A","B"); + star.addEdge(new Edge("f","A","C"),"A","C"); + star.addEdge(new Edge("f","A","D"),"A","D"); + star.addEdge(new Edge("f","A","E"),"A","E"); - complete5 = new UndirectedSparseGraph(); + complete5 = new UndirectedSparseGraph(); String[] k5 = {"A","B","C","D","E"}; for (String v : k5) complete5.addVertex(v); for (int i = 0; i < k5.length; i++) for (int j = i+1; j < k5.length; j++) { - edge e = new edge("f", k5[i], k5[j]); e.setWeight((float)(i+j)); + Edge e = new Edge("f", k5[i], k5[j]); e.setWeight((float)(i+j)); complete5.addEdge(e, k5[i], k5[j]); } - disconnected = new UndirectedSparseGraph(); + disconnected = new UndirectedSparseGraph(); for (String v : new String[]{"A","B","C","D"}) disconnected.addVertex(v); - disconnected.addEdge(new edge("f","A","B"),"A","B"); - disconnected.addEdge(new edge("f","C","D"),"C","D"); + disconnected.addEdge(new Edge("f","A","B"),"A","B"); + disconnected.addEdge(new Edge("f","C","D"),"C","D"); - single = new UndirectedSparseGraph(); + single = new UndirectedSparseGraph(); single.addVertex("A"); - empty = new UndirectedSparseGraph(); + empty = new UndirectedSparseGraph(); - weighted = new UndirectedSparseGraph(); + weighted = new UndirectedSparseGraph(); for (String v : new String[]{"A","B","C","D"}) weighted.addVertex(v); - edge e1=new edge("f","A","B"); e1.setWeight(1f); - edge e2=new edge("f","B","C"); e2.setWeight(5f); - edge e3=new edge("f","C","D"); e3.setWeight(3f); - edge e4=new edge("f","A","D"); e4.setWeight(2f); - edge e5=new edge("f","A","C"); e5.setWeight(4f); + edge e1=new Edge("f","A","B"); e1.setWeight(1f); + edge e2=new Edge("f","B","C"); e2.setWeight(5f); + edge e3=new Edge("f","C","D"); e3.setWeight(3f); + edge e4=new Edge("f","A","D"); e4.setWeight(2f); + edge e5=new Edge("f","A","C"); e5.setWeight(4f); weighted.addEdge(e1,"A","B"); weighted.addEdge(e2,"B","C"); weighted.addEdge(e3,"C","D"); weighted.addEdge(e4,"A","D"); weighted.addEdge(e5,"A","C"); @@ -87,14 +87,14 @@ public void setUp() { @Test public void testImportanceK5() { assertEquals(10, new GraphSparsificationAnalyzer(complete5).scoreEdgeImportance().size()); } // Spanning Tree - @Test public void testSTTriangle() { Graph st = new GraphSparsificationAnalyzer(triangle).spanningTreeSparsify(); assertEquals(3, st.getVertexCount()); assertEquals(2, st.getEdgeCount()); } + @Test public void testSTTriangle() { Graph st = new GraphSparsificationAnalyzer(triangle).spanningTreeSparsify(); assertEquals(3, st.getVertexCount()); assertEquals(2, st.getEdgeCount()); } @Test public void testSTK5() { assertEquals(4, new GraphSparsificationAnalyzer(complete5).spanningTreeSparsify().getEdgeCount()); } @Test public void testSTDisconnected() { assertEquals(2, new GraphSparsificationAnalyzer(disconnected).spanningTreeSparsify().getEdgeCount()); } @Test public void testSTSingle() { assertEquals(0, new GraphSparsificationAnalyzer(single).spanningTreeSparsify().getEdgeCount()); } // Random @Test public void testRandAll() { assertEquals(10, new GraphSparsificationAnalyzer(complete5).randomSparsify(1.0, 42).getEdgeCount()); } - @Test public void testRandNone() { Graph s = new GraphSparsificationAnalyzer(complete5).randomSparsify(0.0, 42); assertEquals(0, s.getEdgeCount()); assertEquals(5, s.getVertexCount()); } + @Test public void testRandNone() { Graph s = new GraphSparsificationAnalyzer(complete5).randomSparsify(0.0, 42); assertEquals(0, s.getEdgeCount()); assertEquals(5, s.getVertexCount()); } @Test public void testRandDeterministic() { GraphSparsificationAnalyzer a = new GraphSparsificationAnalyzer(complete5); assertEquals(a.randomSparsify(0.5,42).getEdgeCount(), a.randomSparsify(0.5,42).getEdgeCount()); } @Test(expected = IllegalArgumentException.class) public void testRandInvalid() { new GraphSparsificationAnalyzer(complete5).randomSparsify(1.5, 42); } @@ -104,7 +104,7 @@ public void setUp() { @Test public void testThresholdZero() { assertEquals(5, new GraphSparsificationAnalyzer(weighted).thresholdSparsify(0f).getEdgeCount()); } // Local - @Test public void testLocalK1() { Graph s = new GraphSparsificationAnalyzer(weighted).localSparsify(1); assertTrue(s.getEdgeCount() >= 1 && s.getEdgeCount() <= 4); } + @Test public void testLocalK1() { Graph s = new GraphSparsificationAnalyzer(weighted).localSparsify(1); assertTrue(s.getEdgeCount() >= 1 && s.getEdgeCount() <= 4); } @Test public void testLocalHighK() { assertEquals(5, new GraphSparsificationAnalyzer(weighted).localSparsify(100).getEdgeCount()); } @Test(expected = IllegalArgumentException.class) public void testLocalInvalid() { new GraphSparsificationAnalyzer(weighted).localSparsify(0); } @@ -122,9 +122,9 @@ public void setUp() { } @Test public void testQualityBroken() { GraphSparsificationAnalyzer a = new GraphSparsificationAnalyzer(path); - Graph b = new UndirectedSparseGraph(); + Graph b = new UndirectedSparseGraph(); for (String v : path.getVertices()) b.addVertex(v); - b.addEdge(new edge("f","A","B"),"A","B"); b.addEdge(new edge("f","C","D"),"C","D"); + b.addEdge(new Edge("f","A","B"),"A","B"); b.addEdge(new Edge("f","C","D"),"C","D"); assertFalse(a.evaluateQuality(b).connectivityPreserved); } @Test(expected = IllegalArgumentException.class) public void testQualityNull() { new GraphSparsificationAnalyzer(triangle).evaluateQuality(null); } @@ -149,8 +149,8 @@ public void setUp() { @Test public void testReportBridges() { assertTrue(new GraphSparsificationAnalyzer(path).generateReport().contains("Bridge Edges")); } // Edge cases - @Test public void testSingleEdge() { Graph g = new UndirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); g.addEdge(new edge("f","A","B"),"A","B"); GraphSparsificationAnalyzer a = new GraphSparsificationAnalyzer(g); assertEquals(1, a.findBridges().size()); assertEquals(1, a.spanningTreeSparsify().getEdgeCount()); } - @Test public void testWeightedST() { Graph st = new GraphSparsificationAnalyzer(weighted).spanningTreeSparsify(); assertEquals(3, st.getEdgeCount()); assertEquals(4, st.getVertexCount()); } + @Test public void testSingleEdge() { Graph g = new UndirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); g.addEdge(new Edge("f","A","B"),"A","B"); GraphSparsificationAnalyzer a = new GraphSparsificationAnalyzer(g); assertEquals(1, a.findBridges().size()); assertEquals(1, a.spanningTreeSparsify().getEdgeCount()); } + @Test public void testWeightedST() { Graph st = new GraphSparsificationAnalyzer(weighted).spanningTreeSparsify(); assertEquals(3, st.getEdgeCount()); assertEquals(4, st.getVertexCount()); } @Test public void testLocalPreservesV() { assertEquals(5, new GraphSparsificationAnalyzer(complete5).localSparsify(2).getVertexCount()); } @Test public void testRandPreservesV() { assertEquals(5, new GraphSparsificationAnalyzer(complete5).randomSparsify(0.3, 123).getVertexCount()); } @Test public void testQualityDensity() { GraphSparsificationAnalyzer a = new GraphSparsificationAnalyzer(complete5); GraphSparsificationAnalyzer.SparsificationQuality q = a.evaluateQuality(a.spanningTreeSparsify()); assertEquals(1.0, q.originalDensity, 0.001); assertTrue(q.sparseDensity < q.originalDensity); } diff --git a/Gvisual/test/gvisual/GraphStatsTest.java b/Gvisual/test/gvisual/GraphStatsTest.java index 1a47ca2..1ab39be 100644 --- a/Gvisual/test/gvisual/GraphStatsTest.java +++ b/Gvisual/test/gvisual/GraphStatsTest.java @@ -16,7 +16,7 @@ */ public class GraphStatsTest { - private Graph graph; + private Graph graph; private Vector friendEdges; private Vector fsEdges; private Vector classmateEdges; @@ -25,7 +25,7 @@ public class GraphStatsTest { @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); friendEdges = new Vector(); fsEdges = new Vector(); classmateEdges = new Vector(); @@ -41,12 +41,12 @@ private GraphStats createStats() { // ── Helper ────────────────────────────────────────────────── private edge makeEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); return e; } - private void addToGraph(edge e) { + private void addToGraph(Edge e) { graph.addEdge(e, e.getVertex1(), e.getVertex2()); } diff --git a/Gvisual/test/gvisual/GraphSummarizerTest.java b/Gvisual/test/gvisual/GraphSummarizerTest.java index 1229aa0..679685f 100644 --- a/Gvisual/test/gvisual/GraphSummarizerTest.java +++ b/Gvisual/test/gvisual/GraphSummarizerTest.java @@ -13,17 +13,17 @@ */ public class GraphSummarizerTest { - private Graph graph; - private List friends, fs, classmates, strangers, studyG; + private Graph graph; + private List friends, fs, classmates, strangers, studyG; @Before public void setUp() { - graph = new UndirectedSparseGraph(); - friends = new ArrayList(); - fs = new ArrayList(); - classmates = new ArrayList(); - strangers = new ArrayList(); - studyG = new ArrayList(); + graph = new UndirectedSparseGraph(); + friends = new ArrayList(); + fs = new ArrayList(); + classmates = new ArrayList(); + strangers = new ArrayList(); + studyG = new ArrayList(); } private GraphSummarizer makeSummarizer() { @@ -33,7 +33,7 @@ private GraphSummarizer makeSummarizer() { private edge addEdge(String v1, String v2, String typeCode) { graph.addVertex(v1); graph.addVertex(v2); - edge e = new edge(typeCode, v1, v2); + edge e = new Edge(typeCode, v1, v2); e.setWeight(50.0f); graph.addEdge(e, v1, v2); return e; diff --git a/Gvisual/test/gvisual/GraphSymmetryAnalyzerTest.java b/Gvisual/test/gvisual/GraphSymmetryAnalyzerTest.java index 94fc8f8..4ac0738 100644 --- a/Gvisual/test/gvisual/GraphSymmetryAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphSymmetryAnalyzerTest.java @@ -14,7 +14,7 @@ */ public class GraphSymmetryAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -22,7 +22,7 @@ public void setUp() { } private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/GraphUtilsTest.java b/Gvisual/test/gvisual/GraphUtilsTest.java index ce34c65..043acd4 100644 --- a/Gvisual/test/gvisual/GraphUtilsTest.java +++ b/Gvisual/test/gvisual/GraphUtilsTest.java @@ -15,7 +15,7 @@ */ public class GraphUtilsTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -45,7 +45,7 @@ public void setUp() { private int edgeCounter = 0; private void addEdge(String v1, String v2, String type, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); e.setLabel(v1 + "-" + v2); graph.addEdge(e, v1, v2); @@ -56,19 +56,19 @@ private void addEdge(String v1, String v2, String type, float weight) { @Test public void getOtherEnd_fromVertex1_returnsVertex2() { - edge e = new edge("f", "X", "Y"); + edge e = new Edge("f", "X", "Y"); assertEquals("Y", GraphUtils.getOtherEnd(e, "X")); } @Test public void getOtherEnd_fromVertex2_returnsVertex1() { - edge e = new edge("f", "X", "Y"); + edge e = new Edge("f", "X", "Y"); assertEquals("X", GraphUtils.getOtherEnd(e, "Y")); } @Test public void getOtherEnd_notEndpoint_returnsNull() { - edge e = new edge("f", "X", "Y"); + edge e = new Edge("f", "X", "Y"); assertNull(GraphUtils.getOtherEnd(e, "Z")); } @@ -109,7 +109,7 @@ public void buildAdjacencyMap_subset() { @Test public void buildAdjacencyMap_emptyGraph() { - Graph empty = new UndirectedSparseGraph<>(); + Graph empty = new UndirectedSparseGraph<>(); Map> adj = GraphUtils.buildAdjacencyMap(empty); assertTrue(adj.isEmpty()); } @@ -166,7 +166,7 @@ public void findComponents_twoComponents() { @Test public void findComponents_emptyGraph() { - Graph empty = new UndirectedSparseGraph<>(); + Graph empty = new UndirectedSparseGraph<>(); List> comps = GraphUtils.findComponents(empty); assertTrue(comps.isEmpty()); } @@ -182,7 +182,7 @@ public void findLargestComponent_returnsLargest() { @Test public void findLargestComponent_emptyGraph() { - Graph empty = new UndirectedSparseGraph<>(); + Graph empty = new UndirectedSparseGraph<>(); Set largest = GraphUtils.findLargestComponent(empty); assertTrue(largest.isEmpty()); } @@ -284,7 +284,7 @@ public void cycleRank_withCycle() { @Test public void copyGraph_preservesStructure() { - Graph copy = GraphUtils.copyGraph(graph); + Graph copy = GraphUtils.copyGraph(graph); assertEquals(graph.getVertexCount(), copy.getVertexCount()); assertEquals(graph.getEdgeCount(), copy.getEdgeCount()); @@ -295,7 +295,7 @@ public void copyGraph_preservesStructure() { @Test public void copyGraph_independent() { - Graph copy = GraphUtils.copyGraph(graph); + Graph copy = GraphUtils.copyGraph(graph); copy.removeVertex("A"); // Original should be unaffected assertTrue(graph.containsVertex("A")); @@ -305,8 +305,8 @@ public void copyGraph_independent() { @Test public void copyGraph_preservesEdgeProperties() { - Graph copy = GraphUtils.copyGraph(graph); - for (edge e : copy.getEdges()) { + Graph copy = GraphUtils.copyGraph(graph); + for (Edge e : copy.getEdges()) { assertNotNull(e.getType()); assertNotNull(e.getVertex1()); assertNotNull(e.getVertex2()); @@ -333,14 +333,14 @@ public void computeBetweenness_nonEmpty() { @Test public void computeBetweenness_emptyGraph() { - Graph empty = new UndirectedSparseGraph<>(); + Graph empty = new UndirectedSparseGraph<>(); Map bc = GraphUtils.computeBetweenness(empty); assertTrue(bc.isEmpty()); } @Test public void computeBetweenness_singleNode() { - Graph single = new UndirectedSparseGraph<>(); + Graph single = new UndirectedSparseGraph<>(); single.addVertex("X"); Map bc = GraphUtils.computeBetweenness(single); assertEquals(1, bc.size()); @@ -350,12 +350,12 @@ public void computeBetweenness_singleNode() { @Test public void computeBetweenness_lineGraph() { // A -- B -- C: B has betweenness = 1 (on path A-C) - Graph line = new UndirectedSparseGraph<>(); + Graph line = new UndirectedSparseGraph<>(); line.addVertex("A"); line.addVertex("B"); line.addVertex("C"); - edge e1 = new edge("f", "A", "B"); - edge e2 = new edge("f", "B", "C"); + edge e1 = new Edge("f", "A", "B"); + edge e2 = new Edge("f", "B", "C"); line.addEdge(e1, "A", "B"); line.addEdge(e2, "B", "C"); @@ -369,13 +369,13 @@ public void computeBetweenness_lineGraph() { @Test public void globalEfficiency_completeTriangle() { - Graph tri = new UndirectedSparseGraph<>(); + Graph tri = new UndirectedSparseGraph<>(); tri.addVertex("A"); tri.addVertex("B"); tri.addVertex("C"); - tri.addEdge(new edge("f", "A", "B"), "A", "B"); - tri.addEdge(new edge("f", "B", "C"), "B", "C"); - tri.addEdge(new edge("f", "A", "C"), "A", "C"); + tri.addEdge(new Edge("f", "A", "B"), "A", "B"); + tri.addEdge(new Edge("f", "B", "C"), "B", "C"); + tri.addEdge(new Edge("f", "A", "C"), "A", "C"); double eff = GraphUtils.globalEfficiency(tri); // Complete graph: all distances = 1, efficiency = 1.0 @@ -384,7 +384,7 @@ public void globalEfficiency_completeTriangle() { @Test public void globalEfficiency_singleNode() { - Graph single = new UndirectedSparseGraph<>(); + Graph single = new UndirectedSparseGraph<>(); single.addVertex("X"); assertEquals(0.0, GraphUtils.globalEfficiency(single), 0.001); } @@ -392,7 +392,7 @@ public void globalEfficiency_singleNode() { @Test public void globalEfficiency_disconnected() { // Two isolated nodes: distance infinite, sum = 0 - Graph disc = new UndirectedSparseGraph<>(); + Graph disc = new UndirectedSparseGraph<>(); disc.addVertex("A"); disc.addVertex("B"); assertEquals(0.0, GraphUtils.globalEfficiency(disc), 0.001); @@ -402,12 +402,12 @@ public void globalEfficiency_disconnected() { public void globalEfficiency_lineGraph() { // A-B-C: d(A,B)=1, d(A,C)=2, d(B,C)=1 // sum = 1/1 + 1/2 + 1/1 = 2.5; E = 2*2.5/(3*2) = 5/6 ≈ 0.833 - Graph line = new UndirectedSparseGraph<>(); + Graph line = new UndirectedSparseGraph<>(); line.addVertex("A"); line.addVertex("B"); line.addVertex("C"); - line.addEdge(new edge("f", "A", "B"), "A", "B"); - line.addEdge(new edge("f", "B", "C"), "B", "C"); + line.addEdge(new Edge("f", "A", "B"), "A", "B"); + line.addEdge(new Edge("f", "B", "C"), "B", "C"); double eff = GraphUtils.globalEfficiency(line); assertEquals(5.0 / 6.0, eff, 0.001); diff --git a/Gvisual/test/gvisual/GrowthRateAnalyzerTest.java b/Gvisual/test/gvisual/GrowthRateAnalyzerTest.java index 9af3bbd..4fc732d 100644 --- a/Gvisual/test/gvisual/GrowthRateAnalyzerTest.java +++ b/Gvisual/test/gvisual/GrowthRateAnalyzerTest.java @@ -16,29 +16,29 @@ */ public class GrowthRateAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // ─── Helper methods ─── private edge makeEdge(String type, String v1, String v2, long start, long end) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setTimestamp(start); e.setEndTimestamp(end); return e; } private edge makeEdge(String type, String v1, String v2, long timestamp) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setTimestamp(timestamp); return e; } - private void addEdge(Graph g, edge e) { + private void addEdge(Graph g, edge e) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); if (!g.containsVertex(v1)) g.addVertex(v1); diff --git a/Gvisual/test/gvisual/HamiltonianAnalyzerTest.java b/Gvisual/test/gvisual/HamiltonianAnalyzerTest.java index 1845307..fd52489 100644 --- a/Gvisual/test/gvisual/HamiltonianAnalyzerTest.java +++ b/Gvisual/test/gvisual/HamiltonianAnalyzerTest.java @@ -15,7 +15,7 @@ public class HamiltonianAnalyzerTest { private HamiltonianAnalyzer analyzer; - private Graph graph; + private Graph graph; private int edgeId; @Before @@ -26,7 +26,7 @@ public void setUp() { } private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); e.setLabel("e" + (edgeId++)); if (!graph.containsVertex(v1)) graph.addVertex(v1); diff --git a/Gvisual/test/gvisual/HierarchicalLayoutTest.java b/Gvisual/test/gvisual/HierarchicalLayoutTest.java index 0782931..ba47bc7 100644 --- a/Gvisual/test/gvisual/HierarchicalLayoutTest.java +++ b/Gvisual/test/gvisual/HierarchicalLayoutTest.java @@ -12,50 +12,50 @@ public class HierarchicalLayoutTest { // ── Helpers ────────────────────────────────────────────────────── - private Graph linearDAG(int n) { - Graph g = new DirectedSparseGraph(); + private Graph linearDAG(int n) { + Graph g = new DirectedSparseGraph(); for (int i = 0; i < n; i++) g.addVertex("n" + i); for (int i = 0; i < n - 1; i++) { - edge e = new edge("d", "n" + i, "n" + (i + 1)); + edge e = new Edge("d", "n" + i, "n" + (i + 1)); g.addEdge(e, "n" + i, "n" + (i + 1)); } return g; } - private Graph diamondDAG() { + private Graph diamondDAG() { // A // / \ // B C // \ / // D - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); for (String v : new String[]{"A", "B", "C", "D"}) g.addVertex(v); - g.addEdge(new edge("d", "A", "B"), "A", "B"); - g.addEdge(new edge("d", "A", "C"), "A", "C"); - g.addEdge(new edge("d", "B", "D"), "B", "D"); - g.addEdge(new edge("d", "C", "D"), "C", "D"); + g.addEdge(new Edge("d", "A", "B"), "A", "B"); + g.addEdge(new Edge("d", "A", "C"), "A", "C"); + g.addEdge(new Edge("d", "B", "D"), "B", "D"); + g.addEdge(new Edge("d", "C", "D"), "C", "D"); return g; } - private Graph wideDAG(int width) { + private Graph wideDAG(int width) { // root -> child0, child1, ..., child(width-1) - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); g.addVertex("root"); for (int i = 0; i < width; i++) { String child = "c" + i; g.addVertex(child); - g.addEdge(new edge("d", "root", child), "root", child); + g.addEdge(new Edge("d", "root", child), "root", child); } return g; } - private Graph cycleGraph(int n) { - Graph g = new DirectedSparseGraph(); + private Graph cycleGraph(int n) { + Graph g = new DirectedSparseGraph(); for (int i = 0; i < n; i++) g.addVertex("n" + i); for (int i = 0; i < n; i++) { String from = "n" + i; String to = "n" + ((i + 1) % n); - g.addEdge(new edge("d", from, to), from, to); + g.addEdge(new Edge("d", from, to), from, to); } return g; } @@ -117,7 +117,7 @@ public void toSVG_beforeCompute() { @Test public void emptyGraph() { - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); HierarchicalLayout layout = new HierarchicalLayout(g).compute(); assertTrue(layout.getPositions().isEmpty()); @@ -132,7 +132,7 @@ public void emptyGraph() { @Test public void singleNode() { - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); g.addVertex("solo"); HierarchicalLayout layout = new HierarchicalLayout(g).compute(); @@ -240,10 +240,10 @@ public void cycleGraph_handledGracefully() { @Test public void selfLoop_handled() { - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); - g.addEdge(new edge("d", "A", "B"), "A", "B"); + g.addEdge(new Edge("d", "A", "B"), "A", "B"); HierarchicalLayout layout = new HierarchicalLayout(g).compute(); assertEquals(2, layout.getPositions().size()); @@ -292,7 +292,7 @@ public void toSVG_containsElements() { @Test public void toSVG_emptyGraph() { - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); String svg = new HierarchicalLayout(g).compute().toSVG(800, 600, 15); assertTrue(svg.contains(" g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); - g.addEdge(new edge("d", "A", "B"), "A", "B"); - g.addEdge(new edge("d", "C", "D"), "C", "D"); + g.addEdge(new Edge("d", "A", "B"), "A", "B"); + g.addEdge(new Edge("d", "C", "D"), "C", "D"); HierarchicalLayout layout = new HierarchicalLayout(g).compute(); @@ -383,7 +383,7 @@ public void disconnectedComponents() { @Test public void isolatedVertices() { - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); @@ -401,13 +401,13 @@ public void isolatedVertices() { @Test public void crossingDetection_knownCase() { // Create X-crossing pattern: A->D, B->C where A,B in layer 0 and C,D in layer 1 - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); - g.addEdge(new edge("d", "A", "D"), "A", "D"); - g.addEdge(new edge("d", "B", "C"), "B", "C"); + g.addEdge(new Edge("d", "A", "D"), "A", "D"); + g.addEdge(new Edge("d", "B", "C"), "B", "C"); // With enough crossing sweeps, should minimize crossings HierarchicalLayout layout = new HierarchicalLayout( @@ -459,16 +459,16 @@ public void complexDAG_multiplePathsToSink() { // E F // \ / // G - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); for (String v : new String[]{"A","B","C","D","E","F","G"}) g.addVertex(v); - g.addEdge(new edge("d","A","B"), "A", "B"); - g.addEdge(new edge("d","A","C"), "A", "C"); - g.addEdge(new edge("d","A","D"), "A", "D"); - g.addEdge(new edge("d","B","E"), "B", "E"); - g.addEdge(new edge("d","C","E"), "C", "E"); - g.addEdge(new edge("d","D","F"), "D", "F"); - g.addEdge(new edge("d","E","G"), "E", "G"); - g.addEdge(new edge("d","F","G"), "F", "G"); + g.addEdge(new Edge("d","A","B"), "A", "B"); + g.addEdge(new Edge("d","A","C"), "A", "C"); + g.addEdge(new Edge("d","A","D"), "A", "D"); + g.addEdge(new Edge("d","B","E"), "B", "E"); + g.addEdge(new Edge("d","C","E"), "C", "E"); + g.addEdge(new Edge("d","D","F"), "D", "F"); + g.addEdge(new Edge("d","E","G"), "E", "G"); + g.addEdge(new Edge("d","F","G"), "F", "G"); HierarchicalLayout layout = new HierarchicalLayout(g).compute(); @@ -502,7 +502,7 @@ public void criticalPath_unmodifiable() { @Test(expected = UnsupportedOperationException.class) public void reversedEdges_unmodifiable() { HierarchicalLayout layout = new HierarchicalLayout(cycleGraph(3)).compute(); - layout.getReversedEdges().add(new edge("d", "x", "y")); + layout.getReversedEdges().add(new Edge("d", "x", "y")); } // ── Recompute ──────────────────────────────────────────────────── @@ -520,7 +520,7 @@ public void compute_canCallTwice() { @Test public void largeGraph_completes() { // Build a moderately large DAG (100 nodes, ~200 edges) - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); for (int i = 0; i < 100; i++) g.addVertex("v" + i); Random rng = new Random(42); @@ -531,7 +531,7 @@ public void largeGraph_completes() { if (j < 100) { String from = "v" + i; String to = "v" + j; - edge e = new edge("d", from, to); + edge e = new Edge("d", from, to); try { g.addEdge(e, from, to); } catch (Exception ex) { diff --git a/Gvisual/test/gvisual/IndependentSetAnalyzerTest.java b/Gvisual/test/gvisual/IndependentSetAnalyzerTest.java index eabe2a1..ef309b8 100644 --- a/Gvisual/test/gvisual/IndependentSetAnalyzerTest.java +++ b/Gvisual/test/gvisual/IndependentSetAnalyzerTest.java @@ -14,16 +14,16 @@ */ public class IndependentSetAnalyzerTest { - private Graph emptyGraph; - private Graph singleVertex; - private Graph singleEdge; - private Graph triangle; - private Graph path4; // A-B-C-D - private Graph star5; // center connected to 4 leaves - private Graph cycle5; // 5-cycle - private Graph complete4; - private Graph bipartite; // K_{2,3} - private Graph petersen; // Petersen graph approx + private Graph emptyGraph; + private Graph singleVertex; + private Graph singleEdge; + private Graph triangle; + private Graph path4; // A-B-C-D + private Graph star5; // center connected to 4 leaves + private Graph cycle5; // 5-cycle + private Graph complete4; + private Graph bipartite; // K_{2,3} + private Graph petersen; // Petersen graph approx @Before public void setUp() { @@ -38,48 +38,48 @@ public void setUp() { singleEdge = new UndirectedSparseGraph<>(); singleEdge.addVertex("A"); singleEdge.addVertex("B"); - singleEdge.addEdge(new edge("e1", "A", "B"), "A", "B"); + singleEdge.addEdge(new Edge("e1", "A", "B"), "A", "B"); // Triangle triangle = new UndirectedSparseGraph<>(); for (String v : new String[]{"A", "B", "C"}) triangle.addVertex(v); - triangle.addEdge(new edge("e1", "A", "B"), "A", "B"); - triangle.addEdge(new edge("e2", "B", "C"), "B", "C"); - triangle.addEdge(new edge("e3", "A", "C"), "A", "C"); + triangle.addEdge(new Edge("e1", "A", "B"), "A", "B"); + triangle.addEdge(new Edge("e2", "B", "C"), "B", "C"); + triangle.addEdge(new Edge("e3", "A", "C"), "A", "C"); // Path: A-B-C-D path4 = new UndirectedSparseGraph<>(); for (String v : new String[]{"A", "B", "C", "D"}) path4.addVertex(v); - path4.addEdge(new edge("e1", "A", "B"), "A", "B"); - path4.addEdge(new edge("e2", "B", "C"), "B", "C"); - path4.addEdge(new edge("e3", "C", "D"), "C", "D"); + path4.addEdge(new Edge("e1", "A", "B"), "A", "B"); + path4.addEdge(new Edge("e2", "B", "C"), "B", "C"); + path4.addEdge(new Edge("e3", "C", "D"), "C", "D"); // Star: center=X, leaves=A,B,C,D star5 = new UndirectedSparseGraph<>(); for (String v : new String[]{"X", "A", "B", "C", "D"}) star5.addVertex(v); - star5.addEdge(new edge("e1", "X", "A"), "X", "A"); - star5.addEdge(new edge("e2", "X", "B"), "X", "B"); - star5.addEdge(new edge("e3", "X", "C"), "X", "C"); - star5.addEdge(new edge("e4", "X", "D"), "X", "D"); + star5.addEdge(new Edge("e1", "X", "A"), "X", "A"); + star5.addEdge(new Edge("e2", "X", "B"), "X", "B"); + star5.addEdge(new Edge("e3", "X", "C"), "X", "C"); + star5.addEdge(new Edge("e4", "X", "D"), "X", "D"); // 5-cycle: A-B-C-D-E-A cycle5 = new UndirectedSparseGraph<>(); for (String v : new String[]{"A", "B", "C", "D", "E"}) cycle5.addVertex(v); - cycle5.addEdge(new edge("e1", "A", "B"), "A", "B"); - cycle5.addEdge(new edge("e2", "B", "C"), "B", "C"); - cycle5.addEdge(new edge("e3", "C", "D"), "C", "D"); - cycle5.addEdge(new edge("e4", "D", "E"), "D", "E"); - cycle5.addEdge(new edge("e5", "E", "A"), "E", "A"); + cycle5.addEdge(new Edge("e1", "A", "B"), "A", "B"); + cycle5.addEdge(new Edge("e2", "B", "C"), "B", "C"); + cycle5.addEdge(new Edge("e3", "C", "D"), "C", "D"); + cycle5.addEdge(new Edge("e4", "D", "E"), "D", "E"); + cycle5.addEdge(new Edge("e5", "E", "A"), "E", "A"); // K4 complete4 = new UndirectedSparseGraph<>(); for (String v : new String[]{"A", "B", "C", "D"}) complete4.addVertex(v); - complete4.addEdge(new edge("e1", "A", "B"), "A", "B"); - complete4.addEdge(new edge("e2", "A", "C"), "A", "C"); - complete4.addEdge(new edge("e3", "A", "D"), "A", "D"); - complete4.addEdge(new edge("e4", "B", "C"), "B", "C"); - complete4.addEdge(new edge("e5", "B", "D"), "B", "D"); - complete4.addEdge(new edge("e6", "C", "D"), "C", "D"); + complete4.addEdge(new Edge("e1", "A", "B"), "A", "B"); + complete4.addEdge(new Edge("e2", "A", "C"), "A", "C"); + complete4.addEdge(new Edge("e3", "A", "D"), "A", "D"); + complete4.addEdge(new Edge("e4", "B", "C"), "B", "C"); + complete4.addEdge(new Edge("e5", "B", "D"), "B", "D"); + complete4.addEdge(new Edge("e6", "C", "D"), "C", "D"); // K_{2,3}: {A,B} x {C,D,E} bipartite = new UndirectedSparseGraph<>(); @@ -87,7 +87,7 @@ public void setUp() { int eid = 0; for (String l : new String[]{"A", "B"}) { for (String r : new String[]{"C", "D", "E"}) { - bipartite.addEdge(new edge("e" + (eid++), l, r), l, r); + bipartite.addEdge(new Edge("e" + (eid++), l, r), l, r); } } } @@ -387,7 +387,7 @@ public void testKernelOnEmptyGraph() { @Test public void testKernelOnIsolatedVertices() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); IndependentSetAnalyzer a = new IndependentSetAnalyzer(g); IndependentSetAnalyzer.KernelResult kr = a.kernelReduction(); @@ -555,7 +555,7 @@ public void testPolynomialOnPath4() { @Test(expected = IllegalStateException.class) public void testPolynomialTooLargeThrows() { - Graph big = new UndirectedSparseGraph<>(); + Graph big = new UndirectedSparseGraph<>(); for (int i = 0; i < 25; i++) big.addVertex("V" + i); IndependentSetAnalyzer a = new IndependentSetAnalyzer(big); a.independencePolynomial(); // > 20 vertices @@ -579,7 +579,7 @@ public void testMaxCliqueOnPath4() { @Test public void testMaxCliqueOnIndependentVertices() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); IndependentSetAnalyzer a = new IndependentSetAnalyzer(g); Set clique = a.maximumCliqueViaComplement(); @@ -658,11 +658,11 @@ public void testReportSummaryContainsVertexCount() { @Test public void testDisconnectedGraph() { // Two components: triangle + isolated vertex - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); - g.addEdge(new edge("e1", "A", "B"), "A", "B"); - g.addEdge(new edge("e2", "B", "C"), "B", "C"); - g.addEdge(new edge("e3", "A", "C"), "A", "C"); + g.addEdge(new Edge("e1", "A", "B"), "A", "B"); + g.addEdge(new Edge("e2", "B", "C"), "B", "C"); + g.addEdge(new Edge("e3", "A", "C"), "A", "C"); IndependentSetAnalyzer a = new IndependentSetAnalyzer(g); Set mis = a.exactMaximumIndependentSet(); assertEquals(2, mis.size()); // 1 from triangle + D @@ -671,10 +671,10 @@ public void testDisconnectedGraph() { @Test public void testTwoDisconnectedEdges() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); - g.addEdge(new edge("e1", "A", "B"), "A", "B"); - g.addEdge(new edge("e2", "C", "D"), "C", "D"); + g.addEdge(new Edge("e1", "A", "B"), "A", "B"); + g.addEdge(new Edge("e2", "C", "D"), "C", "D"); IndependentSetAnalyzer a = new IndependentSetAnalyzer(g); assertEquals(2, a.exactMaximumIndependentSet().size()); } diff --git a/Gvisual/test/gvisual/InfluenceSpreadSimulatorTest.java b/Gvisual/test/gvisual/InfluenceSpreadSimulatorTest.java index 72d3313..97aec12 100644 --- a/Gvisual/test/gvisual/InfluenceSpreadSimulatorTest.java +++ b/Gvisual/test/gvisual/InfluenceSpreadSimulatorTest.java @@ -15,16 +15,16 @@ */ public class InfluenceSpreadSimulatorTest { - private Graph graph; + private Graph graph; private InfluenceSpreadSimulator simulator; @Before public void setUp() { graph = new UndirectedSparseGraph<>(); - graph.addEdge(new edge("c", "A", "B"), "A", "B"); - graph.addEdge(new edge("c", "A", "C"), "A", "C"); - graph.addEdge(new edge("c", "A", "D"), "A", "D"); - graph.addEdge(new edge("c", "A", "E"), "A", "E"); + graph.addEdge(new Edge("c", "A", "B"), "A", "B"); + graph.addEdge(new Edge("c", "A", "C"), "A", "C"); + graph.addEdge(new Edge("c", "A", "D"), "A", "D"); + graph.addEdge(new Edge("c", "A", "E"), "A", "E"); simulator = new InfluenceSpreadSimulator(graph, 42L); } @@ -332,7 +332,7 @@ public void testFindTopKSeeds() { @Test public void testFindTopKSeedsEmptyGraph() { - Graph empty = new UndirectedSparseGraph<>(); + Graph empty = new UndirectedSparseGraph<>(); InfluenceSpreadSimulator sim = new InfluenceSpreadSimulator(empty, 42L); List seeds = sim.findTopKSeeds(3, @@ -404,10 +404,10 @@ public void testVaccinationToString() { @Test public void testEdgeWeightAsInfluenceProbability() { - Graph wg = new UndirectedSparseGraph<>(); - edge e1 = new edge("c", "X", "Y"); + Graph wg = new UndirectedSparseGraph<>(); + edge e1 = new Edge("c", "X", "Y"); e1.setWeight(1.0f); - edge e2 = new edge("c", "X", "Z"); + edge e2 = new Edge("c", "X", "Z"); e2.setWeight(0.0f); wg.addEdge(e1, "X", "Y"); wg.addEdge(e2, "X", "Z"); @@ -423,9 +423,9 @@ public void testEdgeWeightAsInfluenceProbability() { @Test public void testDirectedGraphIC() { - Graph dg = new DirectedSparseGraph<>(); - dg.addEdge(new edge("c", "A", "B"), "A", "B"); - dg.addEdge(new edge("c", "A", "C"), "A", "C"); + Graph dg = new DirectedSparseGraph<>(); + dg.addEdge(new Edge("c", "A", "B"), "A", "B"); + dg.addEdge(new Edge("c", "A", "C"), "A", "C"); InfluenceSpreadSimulator sim = new InfluenceSpreadSimulator(dg, 42L); InfluenceSpreadSimulator.SimulationResult result = @@ -435,8 +435,8 @@ public void testDirectedGraphIC() { @Test public void testDirectedGraphNoBackPropagation() { - Graph dg = new DirectedSparseGraph<>(); - dg.addEdge(new edge("c", "A", "B"), "A", "B"); + Graph dg = new DirectedSparseGraph<>(); + dg.addEdge(new Edge("c", "A", "B"), "A", "B"); InfluenceSpreadSimulator sim = new InfluenceSpreadSimulator(dg, 42L); InfluenceSpreadSimulator.SimulationResult result = @@ -448,11 +448,11 @@ public void testDirectedGraphNoBackPropagation() { @Test public void testChainGraphPropagation() { - Graph chain = new UndirectedSparseGraph<>(); - chain.addEdge(new edge("c", "1", "2"), "1", "2"); - chain.addEdge(new edge("c", "2", "3"), "2", "3"); - chain.addEdge(new edge("c", "3", "4"), "3", "4"); - chain.addEdge(new edge("c", "4", "5"), "4", "5"); + Graph chain = new UndirectedSparseGraph<>(); + chain.addEdge(new Edge("c", "1", "2"), "1", "2"); + chain.addEdge(new Edge("c", "2", "3"), "2", "3"); + chain.addEdge(new Edge("c", "3", "4"), "3", "4"); + chain.addEdge(new Edge("c", "4", "5"), "4", "5"); InfluenceSpreadSimulator sim = new InfluenceSpreadSimulator(chain, 42L); InfluenceSpreadSimulator.SimulationResult result = @@ -465,8 +465,8 @@ public void testChainGraphPropagation() { @Test public void testDisconnectedGraphLimitsSpread() { - Graph dg = new UndirectedSparseGraph<>(); - dg.addEdge(new edge("c", "A", "B"), "A", "B"); + Graph dg = new UndirectedSparseGraph<>(); + dg.addEdge(new Edge("c", "A", "B"), "A", "B"); dg.addVertex("C"); InfluenceSpreadSimulator sim = new InfluenceSpreadSimulator(dg, 42L); diff --git a/Gvisual/test/gvisual/InteractiveHtmlExporterTest.java b/Gvisual/test/gvisual/InteractiveHtmlExporterTest.java index 2e2a8af..9adecf1 100644 --- a/Gvisual/test/gvisual/InteractiveHtmlExporterTest.java +++ b/Gvisual/test/gvisual/InteractiveHtmlExporterTest.java @@ -14,7 +14,7 @@ */ public class InteractiveHtmlExporterTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -24,19 +24,19 @@ public void setUp() { graph.addVertex("Carol"); graph.addVertex("Dave"); - edge e1 = new edge("f", "Alice", "Bob"); + edge e1 = new Edge("f", "Alice", "Bob"); e1.setWeight(1.0f); graph.addEdge(e1, "Alice", "Bob"); - edge e2 = new edge("c", "Bob", "Carol"); + edge e2 = new Edge("c", "Bob", "Carol"); e2.setWeight(0.5f); graph.addEdge(e2, "Bob", "Carol"); - edge e3 = new edge("sg", "Alice", "Carol"); + edge e3 = new Edge("sg", "Alice", "Carol"); e3.setWeight(2.0f); graph.addEdge(e3, "Alice", "Carol"); - edge e4 = new edge("fs", "Carol", "Dave"); + edge e4 = new Edge("fs", "Carol", "Dave"); e4.setWeight(1.0f); graph.addEdge(e4, "Carol", "Dave"); } @@ -174,7 +174,7 @@ public void testExportToFile() throws Exception { @Test public void testEmptyGraph() { - Graph empty = new UndirectedSparseGraph<>(); + Graph empty = new UndirectedSparseGraph<>(); InteractiveHtmlExporter exporter = new InteractiveHtmlExporter(empty); String html = exporter.exportToString(); assertTrue(html.contains("")); @@ -184,7 +184,7 @@ public void testEmptyGraph() { @Test public void testSingleNodeGraph() { - Graph single = new UndirectedSparseGraph<>(); + Graph single = new UndirectedSparseGraph<>(); single.addVertex("Lonely"); InteractiveHtmlExporter exporter = new InteractiveHtmlExporter(single); String html = exporter.exportToString(); diff --git a/Gvisual/test/gvisual/JsonGraphExporterTest.java b/Gvisual/test/gvisual/JsonGraphExporterTest.java index 33579f2..158d990 100644 --- a/Gvisual/test/gvisual/JsonGraphExporterTest.java +++ b/Gvisual/test/gvisual/JsonGraphExporterTest.java @@ -23,7 +23,7 @@ public void testNullGraphThrows() { @Test public void testNullEdgeListAccepted() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); JsonGraphExporter exporter = new JsonGraphExporter(g, null); String json = exporter.exportToString(); assertNotNull(json); @@ -33,8 +33,8 @@ public void testNullEdgeListAccepted() { @Test public void testEmptyGraphJson() { - Graph g = new UndirectedSparseGraph<>(); - JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); + Graph g = new UndirectedSparseGraph<>(); + JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); exporter.setTimestamp("2011-03-15"); String json = exporter.exportToString(); @@ -47,15 +47,15 @@ public void testEmptyGraphJson() { @Test public void testSingleEdgeGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(2.5f); e.setLabel("friends"); g.addEdge(e, "A", "B"); - List edges = new ArrayList<>(); + List edges = new ArrayList<>(); edges.add(e); JsonGraphExporter exporter = new JsonGraphExporter(g, edges); @@ -74,12 +74,12 @@ public void testSingleEdgeGraph() { @Test public void testStatsIncluded() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - edge e1 = new edge("f", "A", "B"); - edge e2 = new edge("c", "B", "C"); + edge e1 = new Edge("f", "A", "B"); + edge e2 = new Edge("c", "B", "C"); g.addEdge(e1, "A", "B"); g.addEdge(e2, "B", "C"); @@ -94,11 +94,11 @@ public void testStatsIncluded() { @Test public void testStatsDisabled() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("X"); - edge e = new edge("s", "X", "X"); + edge e = new Edge("s", "X", "X"); // self-loop won't work in undirected sparse, just test empty stats - JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); + JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); exporter.setIncludeStats(false); String json = exporter.exportToString(); @@ -108,9 +108,9 @@ public void testStatsDisabled() { @Test public void testCompactOutput() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); - JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); + JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); exporter.setPrettyPrint(false); String json = exporter.exportToString(); @@ -120,10 +120,10 @@ public void testCompactOutput() { @Test public void testTimestampOnEdge() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setTimestamp(1300000000000L); e.setEndTimestamp(1300100000000L); g.addEdge(e, "A", "B"); @@ -137,9 +137,9 @@ public void testTimestampOnEdge() { @Test public void testSpecialCharactersEscaped() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("node\"1"); - JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); + JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); String json = exporter.exportToString(); assertTrue(json.contains("node\\\"1")); @@ -147,10 +147,10 @@ public void testSpecialCharactersEscaped() { @Test public void testFileExport() throws IOException { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); g.addEdge(e, "A", "B"); JsonGraphExporter exporter = new JsonGraphExporter(g, Arrays.asList(e)); @@ -166,12 +166,12 @@ public void testFileExport() throws IOException { @Test public void testEdgeTypesPerNode() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - edge e1 = new edge("f", "A", "B"); - edge e2 = new edge("c", "A", "C"); + edge e1 = new Edge("f", "A", "B"); + edge e2 = new Edge("c", "A", "C"); g.addEdge(e1, "A", "B"); g.addEdge(e2, "A", "C"); @@ -186,8 +186,8 @@ public void testEdgeTypesPerNode() { @Test public void testDescriptionInMetadata() { - Graph g = new UndirectedSparseGraph<>(); - JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); + Graph g = new UndirectedSparseGraph<>(); + JsonGraphExporter exporter = new JsonGraphExporter(g, new ArrayList()); exporter.setDescription("Test graph for unit testing"); String json = exporter.exportToString(); diff --git a/Gvisual/test/gvisual/KCoreDecompositionTest.java b/Gvisual/test/gvisual/KCoreDecompositionTest.java index 15676f6..2264793 100644 --- a/Gvisual/test/gvisual/KCoreDecompositionTest.java +++ b/Gvisual/test/gvisual/KCoreDecompositionTest.java @@ -16,17 +16,17 @@ */ public class KCoreDecompositionTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // --- Helpers --- private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/KTrussAnalyzerTest.java b/Gvisual/test/gvisual/KTrussAnalyzerTest.java index 69e84ab..429a593 100644 --- a/Gvisual/test/gvisual/KTrussAnalyzerTest.java +++ b/Gvisual/test/gvisual/KTrussAnalyzerTest.java @@ -15,7 +15,7 @@ */ public class KTrussAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -23,7 +23,7 @@ public void setUp() { } private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); graph.addEdge(e, v1, v2); return e; @@ -81,7 +81,7 @@ public void testGetKTruss() { addEdge("C", "D"); // no triangle KTrussAnalyzer analyzer = new KTrussAnalyzer(graph); - Graph truss3 = analyzer.getKTruss(3); + Graph truss3 = analyzer.getKTruss(3); // The 3-truss should contain only the triangle edges assertTrue(truss3.getEdgeCount() <= 3); @@ -107,7 +107,7 @@ public void testTrussHierarchy() { addEdge("C", "D"); KTrussAnalyzer analyzer = new KTrussAnalyzer(graph); - Map> hierarchy = analyzer.getTrussHierarchy(); + Map> hierarchy = analyzer.getTrussHierarchy(); assertFalse(hierarchy.isEmpty()); } diff --git a/Gvisual/test/gvisual/LaplacianBuilderTest.java b/Gvisual/test/gvisual/LaplacianBuilderTest.java index 927cb32..82abbb8 100644 --- a/Gvisual/test/gvisual/LaplacianBuilderTest.java +++ b/Gvisual/test/gvisual/LaplacianBuilderTest.java @@ -14,7 +14,7 @@ */ public class LaplacianBuilderTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -22,7 +22,7 @@ public void setUp() { } private void addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); graph.addEdge(e, v1, v2); diff --git a/Gvisual/test/gvisual/LineGraphAnalyzerTest.java b/Gvisual/test/gvisual/LineGraphAnalyzerTest.java index 70497f4..6026f70 100644 --- a/Gvisual/test/gvisual/LineGraphAnalyzerTest.java +++ b/Gvisual/test/gvisual/LineGraphAnalyzerTest.java @@ -11,58 +11,58 @@ */ public class LineGraphAnalyzerTest { - private Graph makeGraph(String[][] edges) { - Graph g = new UndirectedSparseGraph(); + private Graph makeGraph(String[][] edges) { + Graph g = new UndirectedSparseGraph(); for (String[] e : edges) { g.addVertex(e[0]); g.addVertex(e[1]); - edge ed = new edge("e", e[0], e[1]); + edge ed = new Edge("e", e[0], e[1]); ed.setLabel(e[0] + "-" + e[1]); g.addEdge(ed, e[0], e[1]); } return g; } - private Graph emptyGraph() { - return new UndirectedSparseGraph(); + private Graph emptyGraph() { + return new UndirectedSparseGraph(); } - private Graph singleVertex() { - Graph g = new UndirectedSparseGraph(); + private Graph singleVertex() { + Graph g = new UndirectedSparseGraph(); g.addVertex("A"); return g; } - private Graph singleEdge() { + private Graph singleEdge() { return makeGraph(new String[][]{{"A", "B"}}); } - private Graph path3() { + private Graph path3() { return makeGraph(new String[][]{{"A", "B"}, {"B", "C"}}); } - private Graph triangle() { + private Graph triangle() { return makeGraph(new String[][]{{"A", "B"}, {"B", "C"}, {"A", "C"}}); } - private Graph k4() { + private Graph k4() { return makeGraph(new String[][]{ {"A", "B"}, {"A", "C"}, {"A", "D"}, {"B", "C"}, {"B", "D"}, {"C", "D"} }); } - private Graph star4() { + private Graph star4() { return makeGraph(new String[][]{{"A", "B"}, {"A", "C"}, {"A", "D"}}); } - private Graph cycle4() { + private Graph cycle4() { return makeGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "A"} }); } - private Graph cycle5() { + private Graph cycle5() { return makeGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "E"}, {"E", "A"} }); @@ -241,7 +241,7 @@ public void testWhitneyEmpty() { @Test public void testWhitneyDisconnected() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); assertTrue(new LineGraphAnalyzer(g).whitneyTheoremCheck().contains("disconnected")); } @@ -261,7 +261,7 @@ public void testWhitneyDisconnected() { public void testMatchDisjoint() { LineGraphAnalyzer a = new LineGraphAnalyzer(k4()); Set m = a.maximalMatchingViaLineGraph(); - Graph lg = a.getLineGraph(); + Graph lg = a.getLineGraph(); List ml = new ArrayList(m); for (int i = 0; i < ml.size(); i++) for (int j = i + 1; j < ml.size(); j++) diff --git a/Gvisual/test/gvisual/LinkPredictionAnalyzerTest.java b/Gvisual/test/gvisual/LinkPredictionAnalyzerTest.java index 2d9edf0..4272f21 100644 --- a/Gvisual/test/gvisual/LinkPredictionAnalyzerTest.java +++ b/Gvisual/test/gvisual/LinkPredictionAnalyzerTest.java @@ -14,11 +14,11 @@ */ public class LinkPredictionAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } @Test(expected = IllegalArgumentException.class) @@ -41,8 +41,8 @@ public void testTrianglePrediction() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -60,8 +60,8 @@ public void testJaccardScoring() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -79,11 +79,11 @@ public void testPreferentialAttachment() { graph.addVertex("C"); graph.addVertex("D"); graph.addVertex("E"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "A", "D"), "A", "D"); - graph.addEdge(new edge("f", "D", "E"), "D", "E"); - graph.addEdge(new edge("f", "C", "E"), "C", "E"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "D"), "A", "D"); + graph.addEdge(new Edge("f", "D", "E"), "D", "E"); + graph.addEdge(new Edge("f", "C", "E"), "C", "E"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -103,10 +103,10 @@ public void testAdamicAdar() { graph.addVertex("B"); graph.addVertex("C"); graph.addVertex("D"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "B", "D"), "B", "D"); - graph.addEdge(new edge("f", "C", "D"), "C", "D"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "B", "D"), "B", "D"); + graph.addEdge(new Edge("f", "C", "D"), "C", "D"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -124,8 +124,8 @@ public void testEnsemblePrediction() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -140,9 +140,9 @@ public void testCompleteGraphNoPredictions() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "B", "C"), "B", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "B", "C"), "B", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -157,7 +157,7 @@ public void testDensityCalculation() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -171,7 +171,7 @@ public void testDensityCalculation() { public void testSummaryNotNull() { graph.addVertex("A"); graph.addVertex("B"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); graph.addVertex("C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); @@ -221,8 +221,8 @@ public void testIsolatedVerticesInLargerGraph() { graph.addVertex("B"); graph.addVertex("C"); graph.addVertex("isolated"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -242,12 +242,12 @@ public void testDisconnectedComponents() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); // Component 2: D-E graph.addVertex("D"); graph.addVertex("E"); - graph.addEdge(new edge("f", "D", "E"), "D", "E"); + graph.addEdge(new Edge("f", "D", "E"), "D", "E"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -271,10 +271,10 @@ public void testTopKLimitsResults() { graph.addVertex("C"); graph.addVertex("D"); graph.addVertex("E"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "A", "D"), "A", "D"); - graph.addEdge(new edge("f", "A", "E"), "A", "E"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "D"), "A", "D"); + graph.addEdge(new Edge("f", "A", "E"), "A", "E"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -289,8 +289,8 @@ public void testTopKZero() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -309,11 +309,11 @@ public void testResultsSortedByScoreDescending() { graph.addVertex("C"); graph.addVertex("D"); graph.addVertex("E"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "A", "D"), "A", "D"); - graph.addEdge(new edge("f", "A", "E"), "A", "E"); - graph.addEdge(new edge("f", "B", "C"), "B", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "D"), "A", "D"); + graph.addEdge(new Edge("f", "A", "E"), "A", "E"); + graph.addEdge(new Edge("f", "B", "C"), "B", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -340,11 +340,11 @@ public void testJaccardWithDifferentSizedNeighborhoods() { graph.addVertex("D"); graph.addVertex("E"); graph.addVertex("F"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "A", "D"), "A", "D"); - graph.addEdge(new edge("f", "A", "E"), "A", "E"); - graph.addEdge(new edge("f", "B", "F"), "B", "F"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "D"), "A", "D"); + graph.addEdge(new Edge("f", "A", "E"), "A", "E"); + graph.addEdge(new Edge("f", "B", "F"), "B", "F"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -371,8 +371,8 @@ public void testAdamicAdarScoreValue() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -390,10 +390,10 @@ public void testAdamicAdarMultipleCommonNeighbors() { graph.addVertex("B"); graph.addVertex("C"); graph.addVertex("D"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "D", "B"), "D", "B"); - graph.addEdge(new edge("f", "D", "C"), "D", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "D", "B"), "D", "B"); + graph.addEdge(new Edge("f", "D", "C"), "D", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -421,11 +421,11 @@ public void testPreferentialAttachmentScoreValue() { graph.addVertex("C"); graph.addVertex("D"); graph.addVertex("E"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "A", "D"), "A", "D"); - graph.addEdge(new edge("f", "D", "E"), "D", "E"); - graph.addEdge(new edge("f", "C", "E"), "C", "E"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "D"), "A", "D"); + graph.addEdge(new Edge("f", "D", "E"), "D", "E"); + graph.addEdge(new Edge("f", "C", "E"), "C", "E"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -451,8 +451,8 @@ public void testPredictionResultMetadata() { graph.addVertex("B"); graph.addVertex("C"); graph.addVertex("D"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "B", "C"), "B", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "B", "C"), "B", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -482,9 +482,9 @@ public void testDensityOneForCompleteGraph() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "B", "C"), "B", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "B", "C"), "B", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -500,8 +500,8 @@ public void testPredictedLinkToString() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -522,9 +522,9 @@ public void testEnsembleReturnsNormalizedScores() { graph.addVertex("B"); graph.addVertex("C"); graph.addVertex("D"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "A", "D"), "A", "D"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "D"), "A", "D"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -554,8 +554,8 @@ public void testSummaryContainsKey() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -578,10 +578,10 @@ public void testCommonNeighborsCorrect() { graph.addVertex("C"); graph.addVertex("D"); // A--B, A--C, D--B, D--C → predict A-D, common = {B, C} - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); - graph.addEdge(new edge("f", "D", "B"), "D", "B"); - graph.addEdge(new edge("f", "D", "C"), "D", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "D", "B"), "D", "B"); + graph.addEdge(new Edge("f", "D", "C"), "D", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -604,8 +604,8 @@ public void testCommonNeighborsUnmodifiable() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = @@ -619,8 +619,8 @@ public void testPredictionsListUnmodifiable() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - graph.addEdge(new edge("f", "A", "B"), "A", "B"); - graph.addEdge(new edge("f", "A", "C"), "A", "C"); + graph.addEdge(new Edge("f", "A", "B"), "A", "B"); + graph.addEdge(new Edge("f", "A", "C"), "A", "C"); LinkPredictionAnalyzer analyzer = new LinkPredictionAnalyzer(graph); LinkPredictionAnalyzer.PredictionResult result = diff --git a/Gvisual/test/gvisual/LouvainCommunityDetectorTest.java b/Gvisual/test/gvisual/LouvainCommunityDetectorTest.java index c20328b..80df844 100644 --- a/Gvisual/test/gvisual/LouvainCommunityDetectorTest.java +++ b/Gvisual/test/gvisual/LouvainCommunityDetectorTest.java @@ -12,17 +12,17 @@ */ public class LouvainCommunityDetectorTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } private void addEdge(String type, String v1, String v2, float weight) { graph.addVertex(v1); graph.addVertex(v2); - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); graph.addEdge(e, v1, v2); } @@ -317,7 +317,7 @@ public void testDeterministic() { @Test public void testZeroWeightEdge() { graph.addVertex("A"); graph.addVertex("B"); - edge e = new edge("f", "A", "B"); e.setWeight(0.0f); + edge e = new Edge("f", "A", "B"); e.setWeight(0.0f); graph.addEdge(e, "A", "B"); LouvainCommunityDetector.LouvainResult r = new LouvainCommunityDetector(graph).detect(); assertEquals(r.getNodeToCommunity().get("A"), r.getNodeToCommunity().get("B")); diff --git a/Gvisual/test/gvisual/MaxCutAnalyzerTest.java b/Gvisual/test/gvisual/MaxCutAnalyzerTest.java index ba3c6ba..e423cda 100644 --- a/Gvisual/test/gvisual/MaxCutAnalyzerTest.java +++ b/Gvisual/test/gvisual/MaxCutAnalyzerTest.java @@ -14,20 +14,20 @@ */ public class MaxCutAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } private void addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); graph.addEdge(e, v1, v2); } private void addWeightedEdge(String v1, String v2, float weight) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(weight); graph.addEdge(e, v1, v2); } @@ -289,7 +289,7 @@ public void testCutResultSetsAreUnmodifiable() { @Test public void testCutEdgesUnmodifiable() { addEdge("A","B"); - try { new MaxCutAnalyzer(graph).computeExact().getCutEdges().add(new edge("f","X","Y")); fail(); } + try { new MaxCutAnalyzer(graph).computeExact().getCutEdges().add(new Edge("f","X","Y")); fail(); } catch (UnsupportedOperationException e) { /* expected */ } } diff --git a/Gvisual/test/gvisual/MetricDimensionAnalyzerTest.java b/Gvisual/test/gvisual/MetricDimensionAnalyzerTest.java index d639464..cb97c2c 100644 --- a/Gvisual/test/gvisual/MetricDimensionAnalyzerTest.java +++ b/Gvisual/test/gvisual/MetricDimensionAnalyzerTest.java @@ -15,41 +15,41 @@ public class MetricDimensionAnalyzerTest { // ── Graph builders ────────────────────────────────────────────── - private Graph makeGraph(String[][] edges) { - Graph g = new UndirectedSparseGraph(); + private Graph makeGraph(String[][] edges) { + Graph g = new UndirectedSparseGraph(); for (String[] e : edges) { g.addVertex(e[0]); g.addVertex(e[1]); - edge ed = new edge("e", e[0], e[1]); + edge ed = new Edge("e", e[0], e[1]); ed.setLabel(e[0] + "-" + e[1]); g.addEdge(ed, e[0], e[1]); } return g; } - private Graph emptyGraph() { - return new UndirectedSparseGraph(); + private Graph emptyGraph() { + return new UndirectedSparseGraph(); } - private Graph singleVertex() { - Graph g = new UndirectedSparseGraph(); + private Graph singleVertex() { + Graph g = new UndirectedSparseGraph(); g.addVertex("A"); return g; } - private Graph path(String... nodes) { - Graph g = new UndirectedSparseGraph(); + private Graph path(String... nodes) { + Graph g = new UndirectedSparseGraph(); for (String v : nodes) g.addVertex(v); for (int i = 0; i < nodes.length - 1; i++) { - edge e = new edge("e", nodes[i], nodes[i + 1]); + edge e = new Edge("e", nodes[i], nodes[i + 1]); e.setLabel(nodes[i] + "-" + nodes[i + 1]); g.addEdge(e, nodes[i], nodes[i + 1]); } return g; } - private Graph cycle(int n) { - Graph g = new UndirectedSparseGraph(); + private Graph cycle(int n) { + Graph g = new UndirectedSparseGraph(); String[] v = new String[n]; for (int i = 0; i < n; i++) { v[i] = String.valueOf((char) ('A' + i)); @@ -57,15 +57,15 @@ private Graph cycle(int n) { } for (int i = 0; i < n; i++) { String a = v[i], b = v[(i + 1) % n]; - edge e = new edge("e", a, b); + edge e = new Edge("e", a, b); e.setLabel(a + "-" + b); g.addEdge(e, a, b); } return g; } - private Graph complete(int n) { - Graph g = new UndirectedSparseGraph(); + private Graph complete(int n) { + Graph g = new UndirectedSparseGraph(); String[] v = new String[n]; for (int i = 0; i < n; i++) { v[i] = String.valueOf((char) ('A' + i)); @@ -73,7 +73,7 @@ private Graph complete(int n) { } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { - edge e = new edge("e", v[i], v[j]); + edge e = new Edge("e", v[i], v[j]); e.setLabel(v[i] + "-" + v[j]); g.addEdge(e, v[i], v[j]); } @@ -81,41 +81,41 @@ private Graph complete(int n) { return g; } - private Graph star(int leaves) { - Graph g = new UndirectedSparseGraph(); + private Graph star(int leaves) { + Graph g = new UndirectedSparseGraph(); g.addVertex("C"); for (int i = 0; i < leaves; i++) { String v = "L" + i; g.addVertex(v); - edge e = new edge("e", "C", v); + edge e = new Edge("e", "C", v); e.setLabel("C-" + v); g.addEdge(e, "C", v); } return g; } - private Graph petersen() { + private Graph petersen() { // Petersen graph: outer cycle 0-4, inner pentagram 5-9 - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); for (int i = 0; i < 10; i++) g.addVertex("V" + i); // Outer cycle: 0-1-2-3-4-0 int[][] outer = {{0,1},{1,2},{2,3},{3,4},{4,0}}; for (int[] e : outer) { - edge ed = new edge("e", "V" + e[0], "V" + e[1]); + edge ed = new Edge("e", "V" + e[0], "V" + e[1]); ed.setLabel("V" + e[0] + "-V" + e[1]); g.addEdge(ed, "V" + e[0], "V" + e[1]); } // Inner pentagram: 5-7, 7-9, 9-6, 6-8, 8-5 int[][] inner = {{5,7},{7,9},{9,6},{6,8},{8,5}}; for (int[] e : inner) { - edge ed = new edge("e", "V" + e[0], "V" + e[1]); + edge ed = new Edge("e", "V" + e[0], "V" + e[1]); ed.setLabel("V" + e[0] + "-V" + e[1]); g.addEdge(ed, "V" + e[0], "V" + e[1]); } // Spokes: 0-5, 1-6, 2-7, 3-8, 4-9 int[][] spokes = {{0,5},{1,6},{2,7},{3,8},{4,9}}; for (int[] e : spokes) { - edge ed = new edge("e", "V" + e[0], "V" + e[1]); + edge ed = new Edge("e", "V" + e[0], "V" + e[1]); ed.setLabel("V" + e[0] + "-V" + e[1]); g.addEdge(ed, "V" + e[0], "V" + e[1]); } @@ -258,7 +258,7 @@ public void testDistanceMatrixPath() { @Test public void testDistanceMatrixDisconnected() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); MetricDimensionAnalyzer a = new MetricDimensionAnalyzer(g); @@ -527,11 +527,11 @@ public void testSummaryEmptyGraph() { @Test public void testDisconnectedGraph() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - edge e = new edge("e", "A", "B"); + edge e = new Edge("e", "A", "B"); e.setLabel("A-B"); g.addEdge(e, "A", "B"); // C is isolated — disconnected graph @@ -543,7 +543,7 @@ public void testDisconnectedGraph() { @Test public void testTwoIsolatedVertices() { - Graph g = new UndirectedSparseGraph(); + Graph g = new UndirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); MetricDimensionAnalyzer a = new MetricDimensionAnalyzer(g); diff --git a/Gvisual/test/gvisual/MinimumSpanningTreeTest.java b/Gvisual/test/gvisual/MinimumSpanningTreeTest.java index d23459a..eff5a51 100644 --- a/Gvisual/test/gvisual/MinimumSpanningTreeTest.java +++ b/Gvisual/test/gvisual/MinimumSpanningTreeTest.java @@ -14,11 +14,11 @@ */ public class MinimumSpanningTreeTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // ========================================== @@ -83,7 +83,7 @@ public void testTwoDisconnectedVertices() { @Test public void testSingleEdge() { - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(5.0f); graph.addEdge(e1, "A", "B"); @@ -105,11 +105,11 @@ public void testSingleEdge() { @Test public void testTrianglePicksLightestTwoEdges() { // Triangle: A-B(1), B-C(2), A-C(3) → MST = A-B(1) + B-C(2) = weight 3 - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(2.0f); - edge e3 = new edge("f", "A", "C"); + edge e3 = new Edge("f", "A", "C"); e3.setWeight(3.0f); graph.addEdge(e1, "A", "B"); @@ -133,11 +133,11 @@ public void testSquareGraphSelectsCorrectEdges() { // Square: A-B(1), B-C(4), C-D(2), A-D(3) // Also diagonal: A-C(5) // MST = A-B(1) + C-D(2) + A-D(3) = weight 6 - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("c", "B", "C"); e2.setWeight(4.0f); - edge e3 = new edge("f", "C", "D"); e3.setWeight(2.0f); - edge e4 = new edge("s", "A", "D"); e4.setWeight(3.0f); - edge e5 = new edge("fs", "A", "C"); e5.setWeight(5.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("c", "B", "C"); e2.setWeight(4.0f); + edge e3 = new Edge("f", "C", "D"); e3.setWeight(2.0f); + edge e4 = new Edge("s", "A", "D"); e4.setWeight(3.0f); + edge e5 = new Edge("fs", "A", "C"); e5.setWeight(5.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -160,7 +160,7 @@ public void testMstHasNMinus1Edges() { float w = 1.0f; for (int i = 0; i < nodes.length; i++) { for (int j = i + 1; j < nodes.length; j++) { - edge e = new edge("f", nodes[i], nodes[j]); + edge e = new Edge("f", nodes[i], nodes[j]); e.setWeight(w); graph.addEdge(e, nodes[i], nodes[j]); w += 1.0f; @@ -181,13 +181,13 @@ public void testMstHasNMinus1Edges() { @Test public void testDisconnectedGraphProducesForest() { // Component 1: A-B(1), B-C(2) - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(2.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(2.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); // Component 2: D-E(3) - edge e3 = new edge("c", "D", "E"); e3.setWeight(3.0f); + edge e3 = new Edge("c", "D", "E"); e3.setWeight(3.0f); graph.addEdge(e3, "D", "E"); MinimumSpanningTree mst = new MinimumSpanningTree(graph); @@ -202,13 +202,13 @@ public void testDisconnectedGraphProducesForest() { @Test public void testForestComponentBreakdown() { // Component 1: A-B(1), B-C(2) - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(2.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(2.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); // Component 2: D-E(5) - edge e3 = new edge("c", "D", "E"); e3.setWeight(5.0f); + edge e3 = new Edge("c", "D", "E"); e3.setWeight(5.0f); graph.addEdge(e3, "D", "E"); // Isolated vertex @@ -250,9 +250,9 @@ public void testIsolatedVerticesAsSingletonComponents() { @Test public void testEqualWeightsProducesValidMst() { // All edges weight 1 — any spanning tree is MST - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(1.0f); - edge e3 = new edge("f", "A", "C"); e3.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(1.0f); + edge e3 = new Edge("f", "A", "C"); e3.setWeight(1.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -268,8 +268,8 @@ public void testEqualWeightsProducesValidMst() { @Test public void testZeroWeightEdges() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(0.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(0.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(0.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(0.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -283,8 +283,8 @@ public void testZeroWeightEdges() { @Test public void testLargeWeights() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1000000.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(999999.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1000000.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(999999.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -302,10 +302,10 @@ public void testLargeWeights() { @Test public void testEdgeTypeDistribution() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("c", "B", "C"); e2.setWeight(2.0f); - edge e3 = new edge("f", "C", "D"); e3.setWeight(3.0f); - edge e4 = new edge("s", "D", "E"); e4.setWeight(4.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("c", "B", "C"); e2.setWeight(2.0f); + edge e3 = new Edge("f", "C", "D"); e3.setWeight(3.0f); + edge e4 = new Edge("s", "D", "E"); e4.setWeight(4.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -331,8 +331,8 @@ public void testEdgeTypeDistributionEmpty() { @Test public void testEdgeTypeDistributionAllSameType() { - edge e1 = new edge("sg", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("sg", "B", "C"); e2.setWeight(2.0f); + edge e1 = new Edge("sg", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("sg", "B", "C"); e2.setWeight(2.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -351,9 +351,9 @@ public void testEdgeTypeDistributionAllSameType() { @Test public void testHeaviestEdge() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(5.0f); - edge e3 = new edge("f", "C", "D"); e3.setWeight(3.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(5.0f); + edge e3 = new Edge("f", "C", "D"); e3.setWeight(3.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -376,9 +376,9 @@ public void testHeaviestEdgeEmpty() { @Test public void testLightestEdge() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(3.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(1.0f); - edge e3 = new edge("f", "C", "D"); e3.setWeight(5.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(3.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(1.0f); + edge e3 = new Edge("f", "C", "D"); e3.setWeight(5.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -401,9 +401,9 @@ public void testLightestEdgeEmpty() { @Test public void testAverageWeight() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(2.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(4.0f); - edge e3 = new edge("f", "C", "D"); e3.setWeight(6.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(2.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(4.0f); + edge e3 = new Edge("f", "C", "D"); e3.setWeight(6.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -425,8 +425,8 @@ public void testAverageWeightEmpty() { @Test public void testGetSummaryConnected() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(2.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(2.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -443,7 +443,7 @@ public void testGetSummaryConnected() { @Test public void testGetSummaryForest() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); graph.addEdge(e1, "A", "B"); graph.addVertex("C"); @@ -462,13 +462,13 @@ public void testGetSummaryForest() { @Test public void testComponentWeights() { // Comp1: A-B(1) B-C(2) → weight 3 - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(2.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(2.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); // Comp2: D-E(7) - edge e3 = new edge("c", "D", "E"); e3.setWeight(7.0f); + edge e3 = new Edge("c", "D", "E"); e3.setWeight(7.0f); graph.addEdge(e3, "D", "E"); MinimumSpanningTree mst = new MinimumSpanningTree(graph); @@ -489,9 +489,9 @@ public void testComponentWeights() { @Test public void testComponentDominantType() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(2.0f); - edge e3 = new edge("c", "C", "D"); e3.setWeight(3.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(2.0f); + edge e3 = new Edge("c", "C", "D"); e3.setWeight(3.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -516,7 +516,7 @@ public void testComponentDominantTypeNull() { @Test public void testComponentIds() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); graph.addEdge(e1, "A", "B"); graph.addVertex("C"); graph.addVertex("D"); @@ -552,7 +552,7 @@ public void testLargerGraph() { makeEdge("f", "B", "C", 6), makeEdge("c", "C", "E", 2), makeEdge("sg", "D", "E", 7), makeEdge("f", "E", "F", 8) }; - for (edge e : edges) { + for (Edge e : edges) { graph.addEdge(e, e.getVertex1(), e.getVertex2()); } @@ -569,7 +569,7 @@ public void testLargerGraph() { public void testStarGraph() { // Hub (A) connected to 5 leaves for (int i = 0; i < 5; i++) { - edge e = new edge("f", "A", "L" + i); + edge e = new Edge("f", "A", "L" + i); e.setWeight(i + 1.0f); graph.addEdge(e, "A", "L" + i); } @@ -586,7 +586,7 @@ public void testStarGraph() { public void testLinearChain() { // A-B-C-D-E (chain) for (int i = 0; i < 4; i++) { - edge e = new edge("f", "N" + i, "N" + (i + 1)); + edge e = new Edge("f", "N" + i, "N" + (i + 1)); e.setWeight((i + 1) * 2.0f); graph.addEdge(e, "N" + i, "N" + (i + 1)); } @@ -611,7 +611,7 @@ public void testCompleteGraphK4() { }; for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { - edge e = new edge("f", nodes[i], nodes[j]); + edge e = new Edge("f", nodes[i], nodes[j]); e.setWeight(weights[i][j]); graph.addEdge(e, nodes[i], nodes[j]); } @@ -632,9 +632,9 @@ public void testCompleteGraphK4() { @Test public void testMultipleComputesSameResult() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("f", "B", "C"); e2.setWeight(2.0f); - edge e3 = new edge("f", "A", "C"); e3.setWeight(3.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("f", "B", "C"); e2.setWeight(2.0f); + edge e3 = new Edge("f", "A", "C"); e3.setWeight(3.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -652,14 +652,14 @@ public void testMultipleComputesSameResult() { @Test public void testResultIsUnmodifiable() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); graph.addEdge(e1, "A", "B"); MinimumSpanningTree mst = new MinimumSpanningTree(graph); MinimumSpanningTree.MSTResult result = mst.compute(); try { - result.getEdges().add(new edge("f", "X", "Y")); + result.getEdges().add(new Edge("f", "X", "Y")); fail("Should not be able to modify edges list"); } catch (UnsupportedOperationException expected) { // pass @@ -668,7 +668,7 @@ public void testResultIsUnmodifiable() { @Test public void testComponentsUnmodifiable() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); graph.addEdge(e1, "A", "B"); MinimumSpanningTree mst = new MinimumSpanningTree(graph); @@ -688,11 +688,11 @@ public void testComponentsUnmodifiable() { @Test public void testMixedEdgeTypes() { - edge e1 = new edge("f", "A", "B"); e1.setWeight(1.0f); - edge e2 = new edge("c", "B", "C"); e2.setWeight(2.0f); - edge e3 = new edge("s", "C", "D"); e3.setWeight(3.0f); - edge e4 = new edge("fs", "D", "E"); e4.setWeight(4.0f); - edge e5 = new edge("sg", "A", "E"); e5.setWeight(10.0f); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.0f); + edge e2 = new Edge("c", "B", "C"); e2.setWeight(2.0f); + edge e3 = new Edge("s", "C", "D"); e3.setWeight(3.0f); + edge e4 = new Edge("fs", "D", "E"); e4.setWeight(4.0f); + edge e5 = new Edge("sg", "A", "E"); e5.setWeight(10.0f); graph.addEdge(e1, "A", "B"); graph.addEdge(e2, "B", "C"); @@ -769,7 +769,7 @@ public void testUnionFindSelfUnion() { // ========================================== private edge makeEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); return e; } diff --git a/Gvisual/test/gvisual/MotifAnalyzerTest.java b/Gvisual/test/gvisual/MotifAnalyzerTest.java index d324db6..cc26ec7 100644 --- a/Gvisual/test/gvisual/MotifAnalyzerTest.java +++ b/Gvisual/test/gvisual/MotifAnalyzerTest.java @@ -14,17 +14,17 @@ */ public class MotifAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // --- Helpers --- private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/NetworkFlowAnalyzerTest.java b/Gvisual/test/gvisual/NetworkFlowAnalyzerTest.java index c72b7cc..9345b71 100644 --- a/Gvisual/test/gvisual/NetworkFlowAnalyzerTest.java +++ b/Gvisual/test/gvisual/NetworkFlowAnalyzerTest.java @@ -16,17 +16,17 @@ */ public class NetworkFlowAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // --- Helpers --- private edge addEdge(String v1, String v2, float weight) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(weight); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); @@ -201,7 +201,7 @@ public void testTriangleGraph() { @Test public void testDefaultWeight() { // Unweighted edges default to capacity 1.0 - edge e = new edge("f", "A", "B"); + edge e = new Edge("f", "A", "B"); e.setWeight(0); if (!graph.containsVertex("A")) graph.addVertex("A"); if (!graph.containsVertex("B")) graph.addVertex("B"); @@ -285,7 +285,7 @@ public void testMinCutSingleEdge() { addEdge("A", "B", 5.0f); NetworkFlowAnalyzer nfa = new NetworkFlowAnalyzer(graph); nfa.compute("A", "B"); - List cut = nfa.getMinCut(); + List cut = nfa.getMinCut(); assertEquals(1, cut.size()); } @@ -295,7 +295,7 @@ public void testMinCutDisconnected() { graph.addVertex("B"); NetworkFlowAnalyzer nfa = new NetworkFlowAnalyzer(graph); nfa.compute("A", "B"); - List cut = nfa.getMinCut(); + List cut = nfa.getMinCut(); assertEquals(0, cut.size()); } @@ -304,9 +304,9 @@ public void testMinCutUnmodifiable() { addEdge("A", "B", 5.0f); NetworkFlowAnalyzer nfa = new NetworkFlowAnalyzer(graph); nfa.compute("A", "B"); - List cut = nfa.getMinCut(); + List cut = nfa.getMinCut(); try { - cut.add(new edge("f", "X", "Y")); + cut.add(new Edge("f", "X", "Y")); fail("Should throw on modification"); } catch (UnsupportedOperationException e) { // expected @@ -363,7 +363,7 @@ public void testBottleneckEdges() { NetworkFlowAnalyzer nfa = new NetworkFlowAnalyzer(graph); nfa.compute("A", "C"); // A-B is bottleneck (capacity 3, flow 3) - List bottlenecks = nfa.getBottleneckEdges(); + List bottlenecks = nfa.getBottleneckEdges(); assertTrue(bottlenecks.size() >= 1); } @@ -372,9 +372,9 @@ public void testBottleneckEdgesUnmodifiable() { addEdge("A", "B", 5.0f); NetworkFlowAnalyzer nfa = new NetworkFlowAnalyzer(graph); nfa.compute("A", "B"); - List bottlenecks = nfa.getBottleneckEdges(); + List bottlenecks = nfa.getBottleneckEdges(); try { - bottlenecks.add(new edge("f", "X", "Y")); + bottlenecks.add(new Edge("f", "X", "Y")); fail("Should throw on modification"); } catch (UnsupportedOperationException e) { // expected diff --git a/Gvisual/test/gvisual/NetworkReportGeneratorTest.java b/Gvisual/test/gvisual/NetworkReportGeneratorTest.java index 409f65c..13aa895 100644 --- a/Gvisual/test/gvisual/NetworkReportGeneratorTest.java +++ b/Gvisual/test/gvisual/NetworkReportGeneratorTest.java @@ -16,27 +16,27 @@ */ public class NetworkReportGeneratorTest { - private Graph graph; - private List friendEdges; - private List fsEdges; - private List classmateEdges; - private List strangerEdges; - private List studyGEdges; + private Graph graph; + private List friendEdges; + private List fsEdges; + private List classmateEdges; + private List strangerEdges; + private List studyGEdges; @Before public void setUp() { - graph = new UndirectedSparseGraph(); - friendEdges = new ArrayList(); - fsEdges = new ArrayList(); - classmateEdges = new ArrayList(); - strangerEdges = new ArrayList(); - studyGEdges = new ArrayList(); + graph = new UndirectedSparseGraph(); + friendEdges = new ArrayList(); + fsEdges = new ArrayList(); + classmateEdges = new ArrayList(); + strangerEdges = new ArrayList(); + studyGEdges = new ArrayList(); } private edge addEdge(String v1, String v2, String type) { if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(1.0f); graph.addEdge(e, v1, v2); return e; diff --git a/Gvisual/test/gvisual/NetworkRoleClassifierTest.java b/Gvisual/test/gvisual/NetworkRoleClassifierTest.java index 36dfeff..18a72ad 100644 --- a/Gvisual/test/gvisual/NetworkRoleClassifierTest.java +++ b/Gvisual/test/gvisual/NetworkRoleClassifierTest.java @@ -21,13 +21,13 @@ public class NetworkRoleClassifierTest { // ── Helper methods ────────────────────────────────────────── - private static Graph emptyGraph() { + private static Graph emptyGraph() { return new UndirectedSparseGraph<>(); } - private static void addEdge(Graph g, String v1, String v2) { + private static void addEdge(Graph g, String v1, String v2) { String id = v1 + "-" + v2; - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setLabel(id); g.addEdge(e, v1, v2); } @@ -35,8 +35,8 @@ private static void addEdge(Graph g, String v1, String v2) { /** * Builds a star graph: center connected to all spokes, no spoke-spoke edges. */ - private static Graph starGraph(int spokes) { - Graph g = emptyGraph(); + private static Graph starGraph(int spokes) { + Graph g = emptyGraph(); g.addVertex("center"); for (int i = 1; i <= spokes; i++) { String spoke = "s" + i; @@ -48,8 +48,8 @@ private static Graph starGraph(int spokes) { /** * Builds a bridge topology: two cliques connected by a single bridge node. */ - private static Graph bridgeGraph() { - Graph g = emptyGraph(); + private static Graph bridgeGraph() { + Graph g = emptyGraph(); String[] cliqueA = {"A1", "A2", "A3", "A4"}; for (int i = 0; i < cliqueA.length; i++) { for (int j = i + 1; j < cliqueA.length; j++) { @@ -71,8 +71,8 @@ private static Graph bridgeGraph() { /** * Builds a complete graph of n nodes (K_n). */ - private static Graph completeGraph(int n) { - Graph g = emptyGraph(); + private static Graph completeGraph(int n) { + Graph g = emptyGraph(); for (int i = 1; i <= n; i++) g.addVertex("N" + i); for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { @@ -113,7 +113,7 @@ public void distribution_emptyGraph_allZeros() { @Test public void classify_singleIsolatedNode() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("alone"); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); @@ -127,7 +127,7 @@ public void classify_singleIsolatedNode() { @Test public void classify_disconnectedNodes_allIsolates() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("X"); g.addVertex("Y"); g.addVertex("Z"); @@ -143,7 +143,7 @@ public void classify_disconnectedNodes_allIsolates() { @Test public void classify_starGraph_centerIsNotPeripheral() { - Graph g = starGraph(8); + Graph g = starGraph(8); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); NetworkRoleClassifier.NodeRole centerRole = c.getRole("center"); @@ -155,7 +155,7 @@ public void classify_starGraph_centerIsNotPeripheral() { @Test public void classify_starGraph_spokesArePeripheral() { - Graph g = starGraph(8); + Graph g = starGraph(8); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); for (int i = 1; i <= 8; i++) { @@ -169,7 +169,7 @@ public void classify_starGraph_spokesArePeripheral() { @Test public void classify_bridgeGraph_XHighBetweenness() { - Graph g = bridgeGraph(); + Graph g = bridgeGraph(); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); NetworkRoleClassifier.NodeRole xRole = c.getRole("X"); @@ -181,7 +181,7 @@ public void classify_bridgeGraph_XHighBetweenness() { @Test public void classify_bridgeGraph_cliqueNodesNotIsolate() { - Graph g = bridgeGraph(); + Graph g = bridgeGraph(); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); for (String v : new String[]{"A1", "A2", "B1", "B2"}) { @@ -194,7 +194,7 @@ public void classify_bridgeGraph_cliqueNodesNotIsolate() { @Test public void classify_completeGraph_allSameRole() { - Graph g = completeGraph(6); + Graph g = completeGraph(6); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); Set seenRoles = new HashSet<>(); @@ -211,7 +211,7 @@ public void classify_completeGraph_allSameRole() { @Test public void getNodesByRole_returnsCorrectNodes() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("X"); g.addVertex("Y"); NetworkRoleClassifier c = new NetworkRoleClassifier(g); @@ -224,7 +224,7 @@ public void getNodesByRole_returnsCorrectNodes() { @Test public void getNodesByRole_isSorted() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("Z"); g.addVertex("A"); g.addVertex("M"); @@ -236,7 +236,7 @@ public void getNodesByRole_isSorted() { @Test public void getNodesByRole_emptyForUnusedRole() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("A"); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); @@ -247,7 +247,7 @@ public void getNodesByRole_emptyForUnusedRole() { @Test public void distribution_countsMatchTotal() { - Graph g = starGraph(6); + Graph g = starGraph(6); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); NetworkRoleClassifier.RoleDistribution dist = c.getRoleDistribution(); @@ -261,7 +261,7 @@ public void distribution_countsMatchTotal() { @Test public void distribution_percentagesSumTo100() { - Graph g = bridgeGraph(); + Graph g = bridgeGraph(); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); NetworkRoleClassifier.RoleDistribution dist = c.getRoleDistribution(); @@ -276,7 +276,7 @@ public void distribution_percentagesSumTo100() { @Test(expected = IllegalArgumentException.class) public void topByImportance_zeroThrows() { - Graph g = starGraph(3); + Graph g = starGraph(3); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); c.topByImportance(0); @@ -284,7 +284,7 @@ public void topByImportance_zeroThrows() { @Test public void topByImportance_starGraph_centerFirst() { - Graph g = starGraph(6); + Graph g = starGraph(6); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); List top = c.topByImportance(3); @@ -294,7 +294,7 @@ public void topByImportance_starGraph_centerFirst() { @Test public void topByImportance_limitsToN() { - Graph g = starGraph(10); + Graph g = starGraph(10); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); assertEquals(2, c.topByImportance(2).size()); @@ -302,7 +302,7 @@ public void topByImportance_limitsToN() { @Test public void topByImportance_requestMoreThanExists() { - Graph g = starGraph(3); + Graph g = starGraph(3); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); List top = c.topByImportance(100); @@ -313,7 +313,7 @@ public void topByImportance_requestMoreThanExists() { @Test public void generateReport_containsHeader() { - Graph g = starGraph(3); + Graph g = starGraph(3); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); String report = c.generateReport(); @@ -324,7 +324,7 @@ public void generateReport_containsHeader() { @Test public void generateReport_listsAllNodes() { - Graph g = starGraph(4); + Graph g = starGraph(4); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); String report = c.generateReport(); @@ -347,7 +347,7 @@ public void generateReport_emptyGraph_noErrors() { @Test(expected = IllegalStateException.class) public void getRole_beforeClassify_throws() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("A"); new NetworkRoleClassifier(g).getRole("A"); } @@ -382,7 +382,7 @@ public void generateReport_beforeClassify_throws() { @Test public void reclassify_resetsRoles() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("A"); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); @@ -397,7 +397,7 @@ public void reclassify_resetsRoles() { @Test public void nodeRole_toString_includesAllFields() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("solo"); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); @@ -454,7 +454,7 @@ public void percentile_100th_returnsMax() { @Test public void metrics_pairGraph_symmetric() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); addEdge(g, "A", "B"); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); @@ -470,7 +470,7 @@ public void metrics_pairGraph_symmetric() { @Test public void metrics_triangleGraph_fullClustering() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "A", "C"); @@ -484,7 +484,7 @@ public void metrics_triangleGraph_fullClustering() { @Test public void metrics_pathGraph_zeroClustering() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); NetworkRoleClassifier c = new NetworkRoleClassifier(g); @@ -497,7 +497,7 @@ public void metrics_pathGraph_zeroClustering() { @Test public void classify_mixedTopology_multipleRoles() { - Graph g = bridgeGraph(); + Graph g = bridgeGraph(); addEdge(g, "A1", "leaf1"); addEdge(g, "B1", "leaf2"); @@ -515,7 +515,7 @@ public void classify_mixedTopology_multipleRoles() { @Test public void getRole_nonexistentNode_returnsNull() { - Graph g = emptyGraph(); + Graph g = emptyGraph(); g.addVertex("A"); NetworkRoleClassifier c = new NetworkRoleClassifier(g); c.classify(); diff --git a/Gvisual/test/gvisual/NodeCentralityAnalyzerTest.java b/Gvisual/test/gvisual/NodeCentralityAnalyzerTest.java index 8166a1f..66ab13d 100644 --- a/Gvisual/test/gvisual/NodeCentralityAnalyzerTest.java +++ b/Gvisual/test/gvisual/NodeCentralityAnalyzerTest.java @@ -15,17 +15,17 @@ */ public class NodeCentralityAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // --- Helper methods --- private edge addEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/NodeSimilarityAnalyzerTest.java b/Gvisual/test/gvisual/NodeSimilarityAnalyzerTest.java index bce3cd6..f43b9e1 100644 --- a/Gvisual/test/gvisual/NodeSimilarityAnalyzerTest.java +++ b/Gvisual/test/gvisual/NodeSimilarityAnalyzerTest.java @@ -13,17 +13,17 @@ */ public class NodeSimilarityAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } private void addEdge(String v1, String v2, String type) { graph.addVertex(v1); graph.addVertex(v2); - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); graph.addEdge(e, v1, v2); } diff --git a/Gvisual/test/gvisual/PageRankAnalyzerTest.java b/Gvisual/test/gvisual/PageRankAnalyzerTest.java index a709fe1..a5fd6dd 100644 --- a/Gvisual/test/gvisual/PageRankAnalyzerTest.java +++ b/Gvisual/test/gvisual/PageRankAnalyzerTest.java @@ -15,17 +15,17 @@ */ public class PageRankAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // --- Helper methods --- private edge addEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); diff --git a/Gvisual/test/gvisual/PlanarGraphAnalyzerTest.java b/Gvisual/test/gvisual/PlanarGraphAnalyzerTest.java index cd9db0d..18ba678 100644 --- a/Gvisual/test/gvisual/PlanarGraphAnalyzerTest.java +++ b/Gvisual/test/gvisual/PlanarGraphAnalyzerTest.java @@ -17,13 +17,13 @@ public class PlanarGraphAnalyzerTest { private int edgeId = 0; - private Graph newGraph() { + private Graph newGraph() { edgeId = 0; - return new UndirectedSparseGraph(); + return new UndirectedSparseGraph(); } - private void addEdge(Graph g, String v1, String v2) { - edge e = new edge("f", v1, v2); + private void addEdge(Graph g, String v1, String v2) { + edge e = new Edge("f", v1, v2); e.setLabel("e" + (edgeId++)); g.addEdge(e, v1, v2); } @@ -32,7 +32,7 @@ private void addEdge(Graph g, String v1, String v2) { @Test public void testEmptyGraphIsPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); PlanarGraphAnalyzer.PlanarityResult r = PlanarGraphAnalyzer.testPlanarity(g); assertTrue(r.isPlanar()); assertEquals(0, r.getVertices()); @@ -41,7 +41,7 @@ public void testEmptyGraphIsPlanar() { @Test public void testSingleVertexIsPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); g.addVertex("A"); PlanarGraphAnalyzer.PlanarityResult r = PlanarGraphAnalyzer.testPlanarity(g); assertTrue(r.isPlanar()); @@ -50,7 +50,7 @@ public void testSingleVertexIsPlanar() { @Test public void testSingleEdgeIsPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); PlanarGraphAnalyzer.PlanarityResult r = PlanarGraphAnalyzer.testPlanarity(g); assertTrue(r.isPlanar()); @@ -60,7 +60,7 @@ public void testSingleEdgeIsPlanar() { @Test public void testTriangleIsPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -70,7 +70,7 @@ public void testTriangleIsPlanar() { @Test public void testK4IsPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -83,7 +83,7 @@ public void testK4IsPlanar() { @Test public void testK5IsNotPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -96,7 +96,7 @@ public void testK5IsNotPlanar() { @Test public void testK33IsNotPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); String[] left = {"L1", "L2", "L3"}; String[] right = {"R1", "R2", "R3"}; for (String l : left) @@ -108,7 +108,7 @@ public void testK33IsNotPlanar() { @Test public void testPathGraphIsPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); for (int i = 0; i < 10; i++) addEdge(g, "V" + i, "V" + (i + 1)); assertTrue(PlanarGraphAnalyzer.testPlanarity(g).isPlanar()); @@ -116,7 +116,7 @@ public void testPathGraphIsPlanar() { @Test public void testCycleGraphIsPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); int n = 8; for (int i = 0; i < n; i++) addEdge(g, "V" + i, "V" + ((i + 1) % n)); @@ -126,7 +126,7 @@ public void testCycleGraphIsPlanar() { @Test public void testWheelGraphIsPlanar() { // Wheel W5: center + 5-cycle, always planar - Graph g = newGraph(); + Graph g = newGraph(); g.addVertex("C"); for (int i = 0; i < 5; i++) { addEdge(g, "V" + i, "V" + ((i + 1) % 5)); @@ -137,7 +137,7 @@ public void testWheelGraphIsPlanar() { @Test public void testDisconnectedPlanarGraph() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "D", "E"); @@ -149,7 +149,7 @@ public void testDisconnectedPlanarGraph() { @Test public void testPetersenGraphIsNotPlanar() { // Petersen graph: 10 vertices, 15 edges, non-planar - Graph g = newGraph(); + Graph g = newGraph(); // Outer cycle for (int i = 0; i < 5; i++) addEdge(g, "O" + i, "O" + ((i + 1) % 5)); @@ -164,7 +164,7 @@ public void testPetersenGraphIsNotPlanar() { @Test public void testComponentCount() { - Graph g = newGraph(); + Graph g = newGraph(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); @@ -181,7 +181,7 @@ public void testNullGraphThrows() { @Test public void testExpectedFacesEulerFormula() { // Triangle: V=3, E=3, C=1 → F = 3-3+1+1 = 2 - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -193,7 +193,7 @@ public void testExpectedFacesEulerFormula() { @Test public void testTriangleFaces() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -204,7 +204,7 @@ public void testTriangleFaces() { @Test public void testK4Faces() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -217,7 +217,7 @@ public void testK4Faces() { @Test public void testFacesOfNonPlanarReturnsNull() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -227,7 +227,7 @@ public void testFacesOfNonPlanarReturnsNull() { @Test public void testFaceHasOuterMarker() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -241,7 +241,7 @@ public void testFaceHasOuterMarker() { @Test public void testFaceIds() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -253,7 +253,7 @@ public void testFaceIds() { @Test public void testSquareFaces() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -265,7 +265,7 @@ public void testSquareFaces() { @Test public void testSingleEdgeFaces() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); List faces = PlanarGraphAnalyzer.enumerateFaces(g); assertNotNull(faces); @@ -277,7 +277,7 @@ public void testSingleEdgeFaces() { @Test public void testTriangleDualGraph() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -288,7 +288,7 @@ public void testTriangleDualGraph() { @Test public void testK4DualGraph() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -300,7 +300,7 @@ public void testK4DualGraph() { @Test public void testNonPlanarDualReturnsNull() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -310,7 +310,7 @@ public void testNonPlanarDualReturnsNull() { @Test public void testDualGraphSymmetry() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -326,7 +326,7 @@ public void testDualGraphSymmetry() { @Test public void testDualEdgeCount() { // Triangle dual: 2 nodes, should have edges between them - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -338,7 +338,7 @@ public void testDualEdgeCount() { @Test public void testK5KuratowskiSubgraph() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -352,7 +352,7 @@ public void testK5KuratowskiSubgraph() { @Test public void testK33KuratowskiSubgraph() { - Graph g = newGraph(); + Graph g = newGraph(); String[] left = {"L1", "L2", "L3"}; String[] right = {"R1", "R2", "R3"}; for (String l : left) @@ -368,7 +368,7 @@ public void testK33KuratowskiSubgraph() { @Test public void testPlanarGraphHasNoKuratowski() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -377,7 +377,7 @@ public void testPlanarGraphHasNoKuratowski() { @Test public void testKuratowskiHasPaths() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -392,7 +392,7 @@ public void testKuratowskiHasPaths() { @Test public void testPlanarReport() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -406,7 +406,7 @@ public void testPlanarReport() { @Test public void testNonPlanarReport() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -421,7 +421,7 @@ public void testNonPlanarReport() { @Test public void testReportToText() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -433,7 +433,7 @@ public void testReportToText() { @Test public void testNonPlanarReportToText() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -445,7 +445,7 @@ public void testNonPlanarReportToText() { @Test public void testGenusOfK5() { - Graph g = newGraph(); + Graph g = newGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < v.length; i++) for (int j = i + 1; j < v.length; j++) @@ -457,7 +457,7 @@ public void testGenusOfK5() { @Test public void testTreeIsPlanar() { // Binary tree - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "1", "2"); addEdge(g, "1", "3"); addEdge(g, "2", "4"); @@ -469,7 +469,7 @@ public void testTreeIsPlanar() { @Test public void testStarGraphIsPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); for (int i = 0; i < 10; i++) addEdge(g, "C", "V" + i); assertTrue(PlanarGraphAnalyzer.testPlanarity(g).isPlanar()); @@ -477,7 +477,7 @@ public void testStarGraphIsPlanar() { @Test public void testTreeFaces() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "B", "D"); @@ -490,7 +490,7 @@ public void testTreeFaces() { @Test public void testIsolatedVerticesPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); for (int i = 0; i < 5; i++) g.addVertex("V" + i); PlanarGraphAnalyzer.PlanarityResult r = PlanarGraphAnalyzer.testPlanarity(g); assertTrue(r.isPlanar()); @@ -499,7 +499,7 @@ public void testIsolatedVerticesPlanar() { @Test public void testSquareWithDiagonalPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -511,7 +511,7 @@ public void testSquareWithDiagonalPlanar() { @Test public void testSquareWithBothDiagonalsPlanar() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -525,7 +525,7 @@ public void testSquareWithBothDiagonalsPlanar() { @Test public void testCubeGraphIsPlanar() { // Q3 (3-cube / hypercube) has 8 vertices, 12 edges — planar - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "000", "001"); addEdge(g, "000", "010"); addEdge(g, "000", "100"); addEdge(g, "001", "011"); addEdge(g, "001", "101"); addEdge(g, "010", "011"); addEdge(g, "010", "110"); @@ -538,7 +538,7 @@ public void testCubeGraphIsPlanar() { @Test public void testFaceVerticesNotNull() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -551,7 +551,7 @@ public void testFaceVerticesNotNull() { @Test public void testDualFacesMatchEnumeratedFaces() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "A"); @@ -562,7 +562,7 @@ public void testDualFacesMatchEnumeratedFaces() { @Test public void testPlanarReportHasCorrectVertexCount() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); addEdge(g, "B", "C"); addEdge(g, "C", "D"); @@ -575,7 +575,7 @@ public void testPlanarReportHasCorrectVertexCount() { @Test public void testOctahedronIsPlanar() { // Octahedron: 6 vertices, 12 edges, planar - Graph g = newGraph(); + Graph g = newGraph(); // Top and bottom + mid ring String[] mid = {"A", "B", "C", "D"}; for (int i = 0; i < 4; i++) { diff --git a/Gvisual/test/gvisual/RandomWalkAnalyzerTest.java b/Gvisual/test/gvisual/RandomWalkAnalyzerTest.java index 9d4d700..5eaa697 100644 --- a/Gvisual/test/gvisual/RandomWalkAnalyzerTest.java +++ b/Gvisual/test/gvisual/RandomWalkAnalyzerTest.java @@ -14,7 +14,7 @@ */ public class RandomWalkAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -22,7 +22,7 @@ public void setUp() { } private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); graph.addEdge(e, v1, v2); diff --git a/Gvisual/test/gvisual/RichClubAnalyzerTest.java b/Gvisual/test/gvisual/RichClubAnalyzerTest.java index c254124..ddc7daa 100644 --- a/Gvisual/test/gvisual/RichClubAnalyzerTest.java +++ b/Gvisual/test/gvisual/RichClubAnalyzerTest.java @@ -16,10 +16,10 @@ */ public class RichClubAnalyzerTest { - private Graph starGraph; - private Graph completeGraph; - private Graph bipartiteGraph; - private Graph hubAndSpoke; + private Graph starGraph; + private Graph completeGraph; + private Graph bipartiteGraph; + private Graph hubAndSpoke; @Before public void setUp() { @@ -29,7 +29,7 @@ public void setUp() { for (int i = 1; i <= 5; i++) { String leaf = "L" + i; starGraph.addVertex(leaf); - edge e = new edge("c", "center", leaf); + edge e = new Edge("c", "center", leaf); starGraph.addEdge(e, "center", leaf); } @@ -40,7 +40,7 @@ public void setUp() { int eid = 0; for (int i = 0; i < nodes.length; i++) { for (int j = i + 1; j < nodes.length; j++) { - edge e = new edge("c", nodes[i], nodes[j]); + edge e = new Edge("c", nodes[i], nodes[j]); completeGraph.addEdge(e, nodes[i], nodes[j]); } } @@ -54,24 +54,24 @@ public void setUp() { String b = "B" + i; bipartiteGraph.addVertex(a); bipartiteGraph.addVertex(b); - bipartiteGraph.addEdge(new edge("c", "H1", a), "H1", a); - bipartiteGraph.addEdge(new edge("c", "H2", b), "H2", b); + bipartiteGraph.addEdge(new Edge("c", "H1", a), "H1", a); + bipartiteGraph.addEdge(new Edge("c", "H2", b), "H2", b); } - bipartiteGraph.addEdge(new edge("c", "H1", "H2"), "H1", "H2"); + bipartiteGraph.addEdge(new Edge("c", "H1", "H2"), "H1", "H2"); // Hub-and-spoke with interconnected hubs hubAndSpoke = new UndirectedSparseGraph<>(); for (int h = 1; h <= 3; h++) hubAndSpoke.addVertex("Hub" + h); // Connect hubs to each other - hubAndSpoke.addEdge(new edge("c", "Hub1", "Hub2"), "Hub1", "Hub2"); - hubAndSpoke.addEdge(new edge("c", "Hub2", "Hub3"), "Hub2", "Hub3"); - hubAndSpoke.addEdge(new edge("c", "Hub1", "Hub3"), "Hub1", "Hub3"); + hubAndSpoke.addEdge(new Edge("c", "Hub1", "Hub2"), "Hub1", "Hub2"); + hubAndSpoke.addEdge(new Edge("c", "Hub2", "Hub3"), "Hub2", "Hub3"); + hubAndSpoke.addEdge(new Edge("c", "Hub1", "Hub3"), "Hub1", "Hub3"); // Add spokes for (int h = 1; h <= 3; h++) { for (int s = 1; s <= 4; s++) { String spoke = "S" + h + "_" + s; hubAndSpoke.addVertex(spoke); - hubAndSpoke.addEdge(new edge("c", "Hub" + h, spoke), "Hub" + h, spoke); + hubAndSpoke.addEdge(new Edge("c", "Hub" + h, spoke), "Hub" + h, spoke); } } } @@ -311,10 +311,10 @@ public void testJsonExport() { @Test public void testSingleEdgeGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("X"); g.addVertex("Y"); - g.addEdge(new edge("c", "X", "Y"), "X", "Y"); + g.addEdge(new Edge("c", "X", "Y"), "X", "Y"); RichClubAnalyzer rca = new RichClubAnalyzer(g); double phi = rca.richClubCoefficient(0); assertEquals(1.0, phi, 0.001); // 2 nodes, 1 edge, φ = 2*1/(2*1) = 1 @@ -322,11 +322,11 @@ public void testSingleEdgeGraph() { @Test public void testDisconnectedNodes() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - g.addEdge(new edge("c", "A", "B"), "A", "B"); + g.addEdge(new Edge("c", "A", "B"), "A", "B"); // C is isolated (degree 0) RichClubAnalyzer rca = new RichClubAnalyzer(g); List members = rca.getRichClubMembers(0); @@ -362,21 +362,21 @@ public void testDeterministicWithSameSeed() { @Test public void testLargerGraphPerformance() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); // Build a scale-free-ish graph: 50 nodes, preferential attachment for (int i = 0; i < 50; i++) g.addVertex("N" + i); Random r = new Random(99); // Connect in a ring first for (int i = 0; i < 50; i++) { String a = "N" + i, b = "N" + ((i + 1) % 50); - g.addEdge(new edge("c", a, b), a, b); + g.addEdge(new Edge("c", a, b), a, b); } // Add some hub edges for (int i = 0; i < 30; i++) { String hub = "N" + (i % 3); // nodes 0-2 become hubs String target = "N" + (3 + r.nextInt(47)); if (!g.isNeighbor(hub, target)) { - g.addEdge(new edge("c", hub, target), hub, target); + g.addEdge(new Edge("c", hub, target), hub, target); } } diff --git a/Gvisual/test/gvisual/ShortestPathFinderTest.java b/Gvisual/test/gvisual/ShortestPathFinderTest.java index f4e5432..c244136 100644 --- a/Gvisual/test/gvisual/ShortestPathFinderTest.java +++ b/Gvisual/test/gvisual/ShortestPathFinderTest.java @@ -16,15 +16,15 @@ */ public class ShortestPathFinderTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } private edge makeEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); return e; } diff --git a/Gvisual/test/gvisual/SignedGraphAnalyzerTest.java b/Gvisual/test/gvisual/SignedGraphAnalyzerTest.java index 5ac7a39..6315d54 100644 --- a/Gvisual/test/gvisual/SignedGraphAnalyzerTest.java +++ b/Gvisual/test/gvisual/SignedGraphAnalyzerTest.java @@ -14,26 +14,26 @@ */ public class SignedGraphAnalyzerTest { - private Graph emptyGraph; - private Graph singleVertex; - private Graph allPositive; // triangle with all + edges - private Graph balanced; // balanced: A-B+, B-C+, A-C- (two groups) - private Graph unbalanced; // triangle with 2+ and 1- (ppn) - private Graph allNegative; // triangle with all - edges - private Graph path3; // A--B--C with mixed signs - private Graph square; // 4-cycle - private Graph largeBalanced; // larger balanced graph + private Graph emptyGraph; + private Graph singleVertex; + private Graph allPositive; // triangle with all + edges + private Graph balanced; // balanced: A-B+, B-C+, A-C- (two groups) + private Graph unbalanced; // triangle with 2+ and 1- (ppn) + private Graph allNegative; // triangle with all - edges + private Graph path3; // A--B--C with mixed signs + private Graph square; // 4-cycle + private Graph largeBalanced; // larger balanced graph private int edgeCounter = 0; private edge makeEdge(String v1, String v2, float weight) { - edge e = new edge("e", v1, v2); + edge e = new Edge("e", v1, v2); e.setWeight(weight); e.setLabel(weight < 0 ? "-" : "+"); return e; } private edge makeLabelEdge(String v1, String v2, String label) { - edge e = new edge("e", v1, v2); + edge e = new Edge("e", v1, v2); e.setLabel(label); return e; } @@ -442,7 +442,7 @@ public void testFrustratedEdgesBalanced() { @Test public void testFrustratedEdgesUnbalanced() { - List frustrated = new SignedGraphAnalyzer(unbalanced).findFrustratedEdges(); + List frustrated = new SignedGraphAnalyzer(unbalanced).findFrustratedEdges(); assertFalse(frustrated.isEmpty()); } @@ -460,7 +460,7 @@ public void testPredictSignNoMutual() { public void testPredictSignPositive() { // All-positive triangle: A-C exists, but predict via B // Need a graph where A-C doesn't exist but they share neighbors - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addEdge(makeEdge("A","B",1), "A", "B"); g.addEdge(makeEdge("B","C",1), "B", "C"); @@ -479,7 +479,7 @@ public void testPredictSignInvalidVertex() { @Test public void testPredictSignNoEvidence() { // Two disconnected vertices - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); assertEquals(0, new SignedGraphAnalyzer(g).predictSign("A", "B")); } @@ -554,7 +554,7 @@ public void testTriangleCensusToString() { @Test public void testSingleEdgePositive() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addEdge(makeEdge("A","B",1), "A", "B"); SignedGraphAnalyzer a = new SignedGraphAnalyzer(g); @@ -565,7 +565,7 @@ public void testSingleEdgePositive() { @Test public void testSingleEdgeNegative() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addEdge(makeEdge("A","B",-1), "A", "B"); SignedGraphAnalyzer a = new SignedGraphAnalyzer(g); @@ -576,7 +576,7 @@ public void testSingleEdgeNegative() { @Test public void testDisconnectedComponents() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addEdge(makeEdge("A","B",1), "A", "B"); g.addEdge(makeEdge("C","D",-1), "C", "D"); diff --git a/Gvisual/test/gvisual/SmallWorldAnalyzerTest.java b/Gvisual/test/gvisual/SmallWorldAnalyzerTest.java index b61946e..a0f397c 100644 --- a/Gvisual/test/gvisual/SmallWorldAnalyzerTest.java +++ b/Gvisual/test/gvisual/SmallWorldAnalyzerTest.java @@ -15,7 +15,7 @@ */ public class SmallWorldAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -23,7 +23,7 @@ public void setUp() { } private void addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); graph.addEdge(e, v1, v2); } diff --git a/Gvisual/test/gvisual/SpectralAnalyzerTest.java b/Gvisual/test/gvisual/SpectralAnalyzerTest.java index 9dad706..1f7d296 100644 --- a/Gvisual/test/gvisual/SpectralAnalyzerTest.java +++ b/Gvisual/test/gvisual/SpectralAnalyzerTest.java @@ -15,17 +15,17 @@ */ public class SpectralAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); } // --- Helpers --- private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + edge e = new Edge("f", v1, v2); e.setWeight(1.0f); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); @@ -33,13 +33,13 @@ private edge addEdge(String v1, String v2) { return e; } - private Graph completeGraph(int n) { - Graph g = new UndirectedSparseGraph(); + private Graph completeGraph(int n) { + Graph g = new UndirectedSparseGraph(); for (int i = 1; i <= n; i++) g.addVertex("N" + i); int edgeId = 0; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { - edge e = new edge("f", "N" + i, "N" + j); + edge e = new Edge("f", "N" + i, "N" + j); e.setWeight(1.0f); g.addEdge(e, "N" + i, "N" + j); edgeId++; @@ -48,20 +48,20 @@ private Graph completeGraph(int n) { return g; } - private Graph pathGraph(int n) { - Graph g = new UndirectedSparseGraph(); + private Graph pathGraph(int n) { + Graph g = new UndirectedSparseGraph(); for (int i = 1; i <= n; i++) g.addVertex("N" + i); for (int i = 1; i < n; i++) { - edge e = new edge("f", "N" + i, "N" + (i + 1)); + edge e = new Edge("f", "N" + i, "N" + (i + 1)); e.setWeight(1.0f); g.addEdge(e, "N" + i, "N" + (i + 1)); } return g; } - private Graph cycleGraph(int n) { - Graph g = pathGraph(n); - edge e = new edge("f", "N" + n, "N1"); + private Graph cycleGraph(int n) { + Graph g = pathGraph(n); + edge e = new Edge("f", "N" + n, "N1"); e.setWeight(1.0f); g.addEdge(e, "N" + n, "N1"); return g; diff --git a/Gvisual/test/gvisual/SteinerTreeAnalyzerTest.java b/Gvisual/test/gvisual/SteinerTreeAnalyzerTest.java index 9bedb05..af8969d 100644 --- a/Gvisual/test/gvisual/SteinerTreeAnalyzerTest.java +++ b/Gvisual/test/gvisual/SteinerTreeAnalyzerTest.java @@ -16,29 +16,29 @@ public class SteinerTreeAnalyzerTest { private int edgeId = 0; - private edge addEdge(Graph g, String u, String v, float w) { - edge e = new edge("e", u, v); + private edge addEdge(Graph g, String u, String v, float w) { + edge e = new Edge("e", u, v); e.setWeight(w); e.setLabel("e" + (edgeId++)); g.addEdge(e, u, v); return e; } - private edge addEdge(Graph g, String u, String v) { + private edge addEdge(Graph g, String u, String v) { return addEdge(g, u, v, 1.0f); } // ── Simple graphs ───────────────────────────────────────────── - private Graph makePath(String... vertices) { - Graph g = new UndirectedSparseGraph<>(); + private Graph makePath(String... vertices) { + Graph g = new UndirectedSparseGraph<>(); for (String v : vertices) g.addVertex(v); for (int i = 0; i < vertices.length - 1; i++) addEdge(g, vertices[i], vertices[i + 1]); return g; } - private Graph makeStar(String center, String... leaves) { - Graph g = new UndirectedSparseGraph<>(); + private Graph makeStar(String center, String... leaves) { + Graph g = new UndirectedSparseGraph<>(); g.addVertex(center); for (String l : leaves) { g.addVertex(l); addEdge(g, center, l); } return g; @@ -55,7 +55,7 @@ public void testNullGraph() { @Test public void testValidateTerminals() { - Graph g = makePath("A", "B", "C"); + Graph g = makePath("A", "B", "C"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); Set valid = sa.validateTerminals(new HashSet<>(Arrays.asList("A", "C", "X"))); assertEquals(new HashSet<>(Arrays.asList("A", "C")), valid); @@ -63,7 +63,7 @@ public void testValidateTerminals() { @Test public void testValidateTerminalsAllInvalid() { - Graph g = makePath("A", "B"); + Graph g = makePath("A", "B"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); assertTrue(sa.validateTerminals(new HashSet<>(Arrays.asList("X", "Y"))).isEmpty()); } @@ -72,14 +72,14 @@ public void testValidateTerminalsAllInvalid() { @Test public void testTerminalsConnected() { - Graph g = makePath("A", "B", "C", "D"); + Graph g = makePath("A", "B", "C", "D"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); assertTrue(sa.areTerminalsConnected(new HashSet<>(Arrays.asList("A", "D")))); } @Test public void testTerminalsDisconnected() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); addEdge(g, "A", "B"); addEdge(g, "C", "D"); @@ -89,7 +89,7 @@ public void testTerminalsDisconnected() { @Test public void testTerminalComponents() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); addEdge(g, "A", "B"); addEdge(g, "C", "D"); @@ -100,7 +100,7 @@ public void testTerminalComponents() { @Test public void testSingleTerminalAlwaysConnected() { - Graph g = makePath("A", "B"); + Graph g = makePath("A", "B"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); assertTrue(sa.areTerminalsConnected(Collections.singleton("A"))); } @@ -109,7 +109,7 @@ public void testSingleTerminalAlwaysConnected() { @Test public void testSPHeuristicSimplePath() { - Graph g = makePath("A", "B", "C"); + Graph g = makePath("A", "B", "C"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.shortestPathHeuristic( new HashSet<>(Arrays.asList("A", "C"))); @@ -120,7 +120,7 @@ public void testSPHeuristicSimplePath() { @Test public void testSPHeuristicStar() { - Graph g = makeStar("C", "A", "B", "D"); + Graph g = makeStar("C", "A", "B", "D"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.shortestPathHeuristic( new HashSet<>(Arrays.asList("A", "B", "D"))); @@ -130,7 +130,7 @@ public void testSPHeuristicStar() { @Test public void testSPHeuristicSingleTerminal() { - Graph g = makePath("A", "B"); + Graph g = makePath("A", "B"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.shortestPathHeuristic(Collections.singleton("A")); assertEquals(0, r.totalWeight, 0.001); @@ -139,19 +139,19 @@ public void testSPHeuristicSingleTerminal() { @Test(expected = IllegalArgumentException.class) public void testSPHeuristicNullTerminals() { - Graph g = makePath("A", "B"); + Graph g = makePath("A", "B"); new SteinerTreeAnalyzer(g).shortestPathHeuristic(null); } @Test(expected = IllegalArgumentException.class) public void testSPHeuristicEmptyTerminals() { - Graph g = makePath("A", "B"); + Graph g = makePath("A", "B"); new SteinerTreeAnalyzer(g).shortestPathHeuristic(Collections.emptySet()); } @Test public void testSPHeuristicWeightedGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C", "D")) g.addVertex(v); addEdge(g, "A", "B", 1); addEdge(g, "B", "C", 1); @@ -167,7 +167,7 @@ public void testSPHeuristicWeightedGraph() { @Test public void testMSTHeuristicSimplePath() { - Graph g = makePath("A", "B", "C"); + Graph g = makePath("A", "B", "C"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.mstHeuristic( new HashSet<>(Arrays.asList("A", "C"))); @@ -176,7 +176,7 @@ public void testMSTHeuristicSimplePath() { @Test public void testMSTHeuristicStar() { - Graph g = makeStar("C", "A", "B", "D"); + Graph g = makeStar("C", "A", "B", "D"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.mstHeuristic( new HashSet<>(Arrays.asList("A", "B", "D"))); @@ -185,7 +185,7 @@ public void testMSTHeuristicStar() { @Test public void testMSTHeuristicSingleTerminal() { - Graph g = makePath("A", "B"); + Graph g = makePath("A", "B"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.mstHeuristic(Collections.singleton("A")); assertEquals(0, r.totalWeight, 0.001); @@ -195,7 +195,7 @@ public void testMSTHeuristicSingleTerminal() { @Test public void testExactSimplePath() { - Graph g = makePath("A", "B", "C"); + Graph g = makePath("A", "B", "C"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.exact( new HashSet<>(Arrays.asList("A", "C"))); @@ -206,7 +206,7 @@ public void testExactSimplePath() { @Test public void testExactStar() { - Graph g = makeStar("C", "A", "B", "D"); + Graph g = makeStar("C", "A", "B", "D"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.exact( new HashSet<>(Arrays.asList("A", "B", "D"))); @@ -216,7 +216,7 @@ public void testExactStar() { @Test public void testExactTwoTerminals() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C")) g.addVertex(v); addEdge(g, "A", "B", 5); addEdge(g, "A", "C", 2); @@ -229,7 +229,7 @@ public void testExactTwoTerminals() { @Test public void testExactSingleTerminal() { - Graph g = makePath("A", "B"); + Graph g = makePath("A", "B"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.exact(Collections.singleton("A")); assertEquals(0, r.totalWeight, 0.001); @@ -238,7 +238,7 @@ public void testExactSingleTerminal() { @Test(expected = IllegalArgumentException.class) public void testExactTooManyTerminals() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); Set terms = new HashSet<>(); for (int i = 0; i < 16; i++) { String v = "V" + i; @@ -251,7 +251,7 @@ public void testExactTooManyTerminals() { @Test public void testExactWeightedDiamond() { // Diamond: A-B(1), A-C(1), B-D(1), C-D(1), A-D(10) - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C", "D")) g.addVertex(v); addEdge(g, "A", "B", 1); addEdge(g, "A", "C", 1); @@ -268,7 +268,7 @@ public void testExactWeightedDiamond() { @Test public void testBestHeuristic() { - Graph g = makeStar("C", "A", "B", "D"); + Graph g = makeStar("C", "A", "B", "D"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.bestHeuristic( new HashSet<>(Arrays.asList("A", "B", "D"))); @@ -279,7 +279,7 @@ public void testBestHeuristic() { @Test public void testSolveSmallUsesExact() { - Graph g = makePath("A", "B", "C"); + Graph g = makePath("A", "B", "C"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.solve( new HashSet<>(Arrays.asList("A", "C"))); @@ -290,7 +290,7 @@ public void testSolveSmallUsesExact() { @Test public void testBottleneckEdge() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C")) g.addVertex(v); addEdge(g, "A", "B", 1); addEdge(g, "B", "C", 5); @@ -304,7 +304,7 @@ public void testBottleneckEdge() { @Test public void testBottleneckEdgeEmpty() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.shortestPathHeuristic(Collections.singleton("A")); @@ -316,7 +316,7 @@ public void testBottleneckEdgeEmpty() { @Test public void testSteinerRatioNoSteinerPoints() { // When all terminals are adjacent, ratio should be ~1 - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C")) g.addVertex(v); addEdge(g, "A", "B", 1); addEdge(g, "B", "C", 1); @@ -331,7 +331,7 @@ public void testSteinerRatioNoSteinerPoints() { @Test public void testSteinerRatioWithSteinerPoints() { // Star topology: terminals at leaves, center is Steiner point - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C", "D", "center")) g.addVertex(v); addEdge(g, "center", "A", 1); addEdge(g, "center", "B", 1); @@ -352,7 +352,7 @@ public void testSteinerRatioWithSteinerPoints() { @Test public void testSteinerPointImportance() { - Graph g = makeStar("C", "A", "B", "D"); + Graph g = makeStar("C", "A", "B", "D"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.shortestPathHeuristic( new HashSet<>(Arrays.asList("A", "B", "D"))); @@ -363,7 +363,7 @@ public void testSteinerPointImportance() { @Test public void testSteinerPointImportanceNoSteinerPoints() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); addEdge(g, "A", "B"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); @@ -376,7 +376,7 @@ public void testSteinerPointImportanceNoSteinerPoints() { @Test public void testTerminalMSTCost() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C")) g.addVertex(v); addEdge(g, "A", "B", 3); addEdge(g, "B", "C", 4); @@ -387,7 +387,7 @@ public void testTerminalMSTCost() { @Test public void testTerminalMSTCostSingle() { - Graph g = makePath("A", "B"); + Graph g = makePath("A", "B"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); assertEquals(0, sa.terminalMSTCost(Collections.singleton("A")), 0.001); } @@ -396,7 +396,7 @@ public void testTerminalMSTCostSingle() { @Test public void testAnalyze() { - Graph g = makeStar("C", "A", "B", "D"); + Graph g = makeStar("C", "A", "B", "D"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerReport report = sa.analyze( new HashSet<>(Arrays.asList("A", "B", "D"))); @@ -406,7 +406,7 @@ public void testAnalyze() { @Test public void testTextReport() { - Graph g = makeStar("C", "A", "B", "D"); + Graph g = makeStar("C", "A", "B", "D"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); String report = sa.textReport(new HashSet<>(Arrays.asList("A", "B", "D"))); assertTrue(report.contains("STEINER TREE ANALYSIS")); @@ -455,7 +455,7 @@ public void testResultAllVertices() { @Test public void testGridGraph() { // 3x3 grid with unit weights - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) g.addVertex(r + "," + c); @@ -475,7 +475,7 @@ public void testGridGraph() { @Test public void testWeightedGraphPrefersCheaperPaths() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C", "D", "E")) g.addVertex(v); addEdge(g, "A", "B", 10); addEdge(g, "A", "D", 1); @@ -490,7 +490,7 @@ public void testWeightedGraphPrefersCheaperPaths() { @Test public void testTwoAdjacentTerminals() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); addEdge(g, "A", "B", 3); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); @@ -502,7 +502,7 @@ public void testTwoAdjacentTerminals() { @Test public void testAllVerticesAreTerminals() { - Graph g = makePath("A", "B", "C"); + Graph g = makePath("A", "B", "C"); SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); SteinerTreeAnalyzer.SteinerTreeResult r = sa.solve( new HashSet<>(Arrays.asList("A", "B", "C"))); @@ -512,7 +512,7 @@ public void testAllVerticesAreTerminals() { @Test public void testSavingsAnalysis() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C", "S")) g.addVertex(v); addEdge(g, "S", "A", 1); addEdge(g, "S", "B", 1); @@ -529,7 +529,7 @@ public void testSavingsAnalysis() { @Test public void testDisconnectedTerminals() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); // No edges SteinerTreeAnalyzer sa = new SteinerTreeAnalyzer(g); @@ -538,7 +538,7 @@ public void testDisconnectedTerminals() { @Test public void testCompleteGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C", "D")) g.addVertex(v); addEdge(g, "A", "B", 1); addEdge(g, "A", "C", 1); @@ -554,7 +554,7 @@ public void testCompleteGraph() { @Test public void testHeuristicsVsExact() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C", "D", "E")) g.addVertex(v); addEdge(g, "A", "D", 1); addEdge(g, "D", "B", 1); diff --git a/Gvisual/test/gvisual/StronglyConnectedComponentsAnalyzerTest.java b/Gvisual/test/gvisual/StronglyConnectedComponentsAnalyzerTest.java index 5637877..45401d8 100644 --- a/Gvisual/test/gvisual/StronglyConnectedComponentsAnalyzerTest.java +++ b/Gvisual/test/gvisual/StronglyConnectedComponentsAnalyzerTest.java @@ -16,30 +16,30 @@ public class StronglyConnectedComponentsAnalyzerTest { // ── Helper methods ────────────────────────────────────────── - private Graph buildDirectedGraph(String[][] edges) { - Graph g = new DirectedSparseGraph(); + private Graph buildDirectedGraph(String[][] edges) { + Graph g = new DirectedSparseGraph(); int edgeId = 0; for (String[] e : edges) { String from = e[0]; String to = e[1]; if (!g.containsVertex(from)) g.addVertex(from); if (!g.containsVertex(to)) g.addVertex(to); - edge ed = new edge("link", from, to); + edge ed = new Edge("link", from, to); ed.setLabel("e" + edgeId++); g.addEdge(ed, from, to); } return g; } - private Graph buildDirectedGraphWithIsolated(String[][] edges, String[] isolated) { - Graph g = buildDirectedGraph(edges); + private Graph buildDirectedGraphWithIsolated(String[][] edges, String[] isolated) { + Graph g = buildDirectedGraph(edges); for (String v : isolated) { if (!g.containsVertex(v)) g.addVertex(v); } return g; } - private void assertBothAlgorithmsAgree(Graph g, int expectedComponents) { + private void assertBothAlgorithmsAgree(Graph g, int expectedComponents) { StronglyConnectedComponentsAnalyzer analyzer = new StronglyConnectedComponentsAnalyzer(g); StronglyConnectedComponentsAnalyzer.SCCResult tarjan = analyzer.tarjan(); StronglyConnectedComponentsAnalyzer.SCCResult kosaraju = analyzer.kosaraju(); @@ -68,7 +68,7 @@ public void testNullGraph() { @Test public void testEmptyGraph() { - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); StronglyConnectedComponentsAnalyzer analyzer = new StronglyConnectedComponentsAnalyzer(g); StronglyConnectedComponentsAnalyzer.SCCResult result = analyzer.tarjan(); assertEquals(0, result.getComponentCount()); @@ -79,7 +79,7 @@ public void testEmptyGraph() { @Test public void testSingleVertex() { - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); g.addVertex("A"); assertBothAlgorithmsAgree(g, 1); @@ -93,7 +93,7 @@ public void testSingleVertex() { @Test public void testTwoVerticesOneEdge() { - Graph g = buildDirectedGraph(new String[][]{{"A", "B"}}); + Graph g = buildDirectedGraph(new String[][]{{"A", "B"}}); assertBothAlgorithmsAgree(g, 2); StronglyConnectedComponentsAnalyzer analyzer = new StronglyConnectedComponentsAnalyzer(g); @@ -107,7 +107,7 @@ public void testTwoVerticesOneEdge() { @Test public void testSimpleCycle() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "A"} }); assertBothAlgorithmsAgree(g, 1); @@ -124,7 +124,7 @@ public void testSimpleCycle() { @Test public void testTwoSCCs() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "A"}, // SCC1: {A,B} {"C", "D"}, {"D", "C"}, // SCC2: {C,D} {"B", "C"} // bridge @@ -143,7 +143,7 @@ public void testTwoSCCs() { @Test public void testDAG() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"A", "C"}, {"B", "D"}, {"C", "D"} }); assertBothAlgorithmsAgree(g, 4); @@ -157,7 +157,7 @@ public void testDAG() { @Test public void testIsolatedVertices() { - Graph g = buildDirectedGraphWithIsolated( + Graph g = buildDirectedGraphWithIsolated( new String[][]{{"A", "B"}, {"B", "A"}}, new String[]{"X", "Y"} ); @@ -169,7 +169,7 @@ public void testIsolatedVertices() { @Test public void testComplexGraph() { // 3 SCCs: {A,B,C}, {D,E}, {F} - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "A"}, // SCC1 {"D", "E"}, {"E", "D"}, // SCC2 {"C", "D"}, {"E", "F"} // bridges @@ -188,7 +188,7 @@ public void testComplexGraph() { @Test public void testClassification() { // source -> intermediate -> sink - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "A"}, // source SCC {"C", "D"}, {"D", "C"}, // intermediate SCC {"E", "F"}, {"F", "E"}, // sink SCC @@ -214,7 +214,7 @@ public void testClassification() { @Test public void testCondensationDAG() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "A"}, {"C", "D"}, {"D", "C"}, {"B", "C"} @@ -222,7 +222,7 @@ public void testCondensationDAG() { StronglyConnectedComponentsAnalyzer analyzer = new StronglyConnectedComponentsAnalyzer(g); StronglyConnectedComponentsAnalyzer.SCCResult result = analyzer.tarjan(); - Graph condensation = result.getCondensation(); + Graph condensation = result.getCondensation(); assertEquals(2, condensation.getVertexCount()); assertEquals(1, condensation.getEdgeCount()); } @@ -231,7 +231,7 @@ public void testCondensationDAG() { @Test public void testLargestComponent() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "D"}, {"D", "A"}, // size 4 {"E", "F"}, {"F", "E"} // size 2 }); @@ -245,7 +245,7 @@ public void testLargestComponent() { @Test public void testVertexLookup() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "A"} }); StronglyConnectedComponentsAnalyzer analyzer = new StronglyConnectedComponentsAnalyzer(g); @@ -260,7 +260,7 @@ public void testVertexLookup() { @Test public void testSelfLoop() { - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); g.addVertex("A"); // Self-loops in JUNG DirectedSparseGraph may not be supported, // but the vertex should still be in its own SCC @@ -274,14 +274,14 @@ public void testSelfLoop() { @Test public void testMinEdgesToConnect() { // Already strongly connected - Graph g1 = buildDirectedGraph(new String[][]{ + Graph g1 = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "A"} }); StronglyConnectedComponentsAnalyzer a1 = new StronglyConnectedComponentsAnalyzer(g1); assertEquals(0, a1.minEdgesToStronglyConnect(a1.tarjan())); // Chain: A->B->C (3 SCCs, 1 source, 1 sink) => need max(1,1) = 1 edge - Graph g2 = buildDirectedGraph(new String[][]{ + Graph g2 = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "C"} }); StronglyConnectedComponentsAnalyzer a2 = new StronglyConnectedComponentsAnalyzer(g2); @@ -292,7 +292,7 @@ public void testMinEdgesToConnect() { @Test public void testReportGeneration() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "A"}, {"C", "D"} }); StronglyConnectedComponentsAnalyzer analyzer = new StronglyConnectedComponentsAnalyzer(g); @@ -318,7 +318,7 @@ public void testCompleteGraph() { } } } - Graph g = buildDirectedGraph(edges.toArray(new String[0][])); + Graph g = buildDirectedGraph(edges.toArray(new String[0][])); assertBothAlgorithmsAgree(g, 1); } @@ -330,7 +330,7 @@ public void testLongChain() { for (int i = 0; i < 9; i++) { edges[i] = new String[]{"N" + i, "N" + (i + 1)}; } - Graph g = buildDirectedGraph(edges); + Graph g = buildDirectedGraph(edges); assertBothAlgorithmsAgree(g, 10); // each node is its own SCC } @@ -343,7 +343,7 @@ public void testLongCycle() { for (int i = 0; i < n; i++) { edges[i] = new String[]{"N" + i, "N" + ((i + 1) % n)}; } - Graph g = buildDirectedGraph(edges); + Graph g = buildDirectedGraph(edges); assertBothAlgorithmsAgree(g, 1); // all in one SCC } @@ -351,7 +351,7 @@ public void testLongCycle() { @Test public void testDiamondPattern() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"A", "C"}, {"B", "D"}, {"C", "D"}, {"D", "A"} // back edge creates one big SCC }); @@ -362,7 +362,7 @@ public void testDiamondPattern() { @Test public void testMultipleSourcesSinks() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "C"}, {"B", "C"}, {"C", "D"}, {"C", "E"} }); StronglyConnectedComponentsAnalyzer analyzer = new StronglyConnectedComponentsAnalyzer(g); @@ -377,7 +377,7 @@ public void testMultipleSourcesSinks() { @Test public void testConnectivityNonExistent() { - Graph g = buildDirectedGraph(new String[][]{{"A", "B"}}); + Graph g = buildDirectedGraph(new String[][]{{"A", "B"}}); StronglyConnectedComponentsAnalyzer analyzer = new StronglyConnectedComponentsAnalyzer(g); StronglyConnectedComponentsAnalyzer.SCCResult result = analyzer.tarjan(); @@ -390,7 +390,7 @@ public void testConnectivityNonExistent() { @Test public void testNestedCycles() { // Inner cycle A-B-C-A, outer cycle A-D-E-C - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "A"}, {"A", "D"}, {"D", "E"}, {"E", "C"} }); @@ -406,7 +406,7 @@ public void testNestedCycles() { @Test public void testParallelBridgeEdges() { // Two SCCs with multiple edges between them - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "A"}, {"C", "D"}, {"D", "C"}, {"A", "C"}, {"B", "D"} // two bridge edges @@ -424,7 +424,7 @@ public void testParallelBridgeEdges() { @Test public void testComponentToString() { - Graph g = buildDirectedGraph(new String[][]{{"A", "B"}, {"B", "A"}}); + Graph g = buildDirectedGraph(new String[][]{{"A", "B"}, {"B", "A"}}); StronglyConnectedComponentsAnalyzer analyzer = new StronglyConnectedComponentsAnalyzer(g); StronglyConnectedComponentsAnalyzer.SCCResult result = analyzer.tarjan(); @@ -437,7 +437,7 @@ public void testComponentToString() { @Test public void testStarTopology() { // Hub A with outgoing edges to B,C,D,E - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"A", "C"}, {"A", "D"}, {"A", "E"} }); assertBothAlgorithmsAgree(g, 5); @@ -447,7 +447,7 @@ public void testStarTopology() { @Test public void testBidirectionalStar() { - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "A"}, {"A", "C"}, {"C", "A"}, {"A", "D"}, {"D", "A"} @@ -461,7 +461,7 @@ public void testBidirectionalStar() { @Test public void testFigureEight() { // Two cycles sharing vertex C - Graph g = buildDirectedGraph(new String[][]{ + Graph g = buildDirectedGraph(new String[][]{ {"A", "B"}, {"B", "C"}, {"C", "A"}, {"C", "D"}, {"D", "E"}, {"E", "C"} }); @@ -472,7 +472,7 @@ public void testFigureEight() { @Test public void testMinEdgesMultipleIsolated() { - Graph g = new DirectedSparseGraph(); + Graph g = new DirectedSparseGraph(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); diff --git a/Gvisual/test/gvisual/StructuralHoleAnalyzerTest.java b/Gvisual/test/gvisual/StructuralHoleAnalyzerTest.java index bdf0a3b..29916ae 100644 --- a/Gvisual/test/gvisual/StructuralHoleAnalyzerTest.java +++ b/Gvisual/test/gvisual/StructuralHoleAnalyzerTest.java @@ -15,43 +15,43 @@ public class StructuralHoleAnalyzerTest { // ── Graph builders ────────────────────────────────────────── - private Graph emptyGraph() { + private Graph emptyGraph() { return new UndirectedSparseGraph<>(); } - private Graph singleVertex() { - Graph g = new UndirectedSparseGraph<>(); + private Graph singleVertex() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); return g; } - private Graph singleEdge() { - Graph g = new UndirectedSparseGraph<>(); + private Graph singleEdge() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); - g.addEdge(new edge("f", "A", "B"), "A", "B"); + g.addEdge(new Edge("f", "A", "B"), "A", "B"); return g; } /** Triangle: A-B, B-C, A-C — fully connected, no structural holes */ - private Graph triangle() { - Graph g = new UndirectedSparseGraph<>(); + private Graph triangle() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - g.addEdge(new edge("f", "A", "B"), "A", "B"); - g.addEdge(new edge("f", "B", "C"), "B", "C"); - g.addEdge(new edge("f", "A", "C"), "A", "C"); + g.addEdge(new Edge("f", "A", "B"), "A", "B"); + g.addEdge(new Edge("f", "B", "C"), "B", "C"); + g.addEdge(new Edge("f", "A", "C"), "A", "C"); return g; } /** Star: center connected to A, B, C, D — spokes not connected */ - private Graph star() { - Graph g = new UndirectedSparseGraph<>(); + private Graph star() { + Graph g = new UndirectedSparseGraph<>(); g.addVertex("center"); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); - g.addEdge(new edge("f", "center", "A"), "center", "A"); - g.addEdge(new edge("f", "center", "B"), "center", "B"); - g.addEdge(new edge("f", "center", "C"), "center", "C"); - g.addEdge(new edge("f", "center", "D"), "center", "D"); + g.addEdge(new Edge("f", "center", "A"), "center", "A"); + g.addEdge(new Edge("f", "center", "B"), "center", "B"); + g.addEdge(new Edge("f", "center", "C"), "center", "C"); + g.addEdge(new Edge("f", "center", "D"), "center", "D"); return g; } @@ -59,56 +59,56 @@ private Graph star() { * Bow-tie: two triangles connected by a single bridge node. * A-B-C triangle, C-D-E triangle, C is the broker. */ - private Graph bowTie() { - Graph g = new UndirectedSparseGraph<>(); + private Graph bowTie() { + Graph g = new UndirectedSparseGraph<>(); for (String v : new String[]{"A", "B", "C", "D", "E"}) g.addVertex(v); - g.addEdge(new edge("f", "A", "B"), "A", "B"); - g.addEdge(new edge("f", "A", "C"), "A", "C"); - g.addEdge(new edge("f", "B", "C"), "B", "C"); - g.addEdge(new edge("f", "C", "D"), "C", "D"); - g.addEdge(new edge("f", "C", "E"), "C", "E"); - g.addEdge(new edge("f", "D", "E"), "D", "E"); + g.addEdge(new Edge("f", "A", "B"), "A", "B"); + g.addEdge(new Edge("f", "A", "C"), "A", "C"); + g.addEdge(new Edge("f", "B", "C"), "B", "C"); + g.addEdge(new Edge("f", "C", "D"), "C", "D"); + g.addEdge(new Edge("f", "C", "E"), "C", "E"); + g.addEdge(new Edge("f", "D", "E"), "D", "E"); return g; } /** Path: A-B-C-D — B and C are brokers between endpoints */ - private Graph path() { - Graph g = new UndirectedSparseGraph<>(); + private Graph path() { + Graph g = new UndirectedSparseGraph<>(); for (String v : new String[]{"A", "B", "C", "D"}) g.addVertex(v); - g.addEdge(new edge("f", "A", "B"), "A", "B"); - g.addEdge(new edge("f", "B", "C"), "B", "C"); - g.addEdge(new edge("f", "C", "D"), "C", "D"); + g.addEdge(new Edge("f", "A", "B"), "A", "B"); + g.addEdge(new Edge("f", "B", "C"), "B", "C"); + g.addEdge(new Edge("f", "C", "D"), "C", "D"); return g; } /** Complete K4 — fully connected, maximum redundancy */ - private Graph complete4() { - Graph g = new UndirectedSparseGraph<>(); + private Graph complete4() { + Graph g = new UndirectedSparseGraph<>(); String[] vs = {"A", "B", "C", "D"}; for (String v : vs) g.addVertex(v); for (int i = 0; i < vs.length; i++) { for (int j = i + 1; j < vs.length; j++) { - g.addEdge(new edge("f", vs[i], vs[j]), vs[i], vs[j]); + g.addEdge(new Edge("f", vs[i], vs[j]), vs[i], vs[j]); } } return g; } /** Two cliques connected by a single bridge */ - private Graph twoClusters() { - Graph g = new UndirectedSparseGraph<>(); + private Graph twoClusters() { + Graph g = new UndirectedSparseGraph<>(); // Cluster 1: A, B, C (triangle) for (String v : new String[]{"A", "B", "C"}) g.addVertex(v); - g.addEdge(new edge("f", "A", "B"), "A", "B"); - g.addEdge(new edge("f", "A", "C"), "A", "C"); - g.addEdge(new edge("f", "B", "C"), "B", "C"); + g.addEdge(new Edge("f", "A", "B"), "A", "B"); + g.addEdge(new Edge("f", "A", "C"), "A", "C"); + g.addEdge(new Edge("f", "B", "C"), "B", "C"); // Cluster 2: D, E, F (triangle) for (String v : new String[]{"D", "E", "F"}) g.addVertex(v); - g.addEdge(new edge("f", "D", "E"), "D", "E"); - g.addEdge(new edge("f", "D", "F"), "D", "F"); - g.addEdge(new edge("f", "E", "F"), "E", "F"); + g.addEdge(new Edge("f", "D", "E"), "D", "E"); + g.addEdge(new Edge("f", "D", "F"), "D", "F"); + g.addEdge(new Edge("f", "E", "F"), "E", "F"); // Bridge: C -- D - g.addEdge(new edge("f", "C", "D"), "C", "D"); + g.addEdge(new Edge("f", "C", "D"), "C", "D"); return g; } @@ -567,7 +567,7 @@ public void testPathEfficiency() { @Test public void testConstraintNonnegative() { - for (Graph g : Arrays.asList(star(), triangle(), bowTie(), path(), complete4())) { + for (Graph g : Arrays.asList(star(), triangle(), bowTie(), path(), complete4())) { StructuralHoleAnalyzer a = new StructuralHoleAnalyzer(g); for (StructuralHoleAnalyzer.VertexMetrics vm : a.analyzeAll()) { assertTrue("Constraint should be non-negative for " + vm.getVertex(), @@ -578,7 +578,7 @@ public void testConstraintNonnegative() { @Test public void testEfficiencyBetweenZeroAndOne() { - for (Graph g : Arrays.asList(star(), triangle(), bowTie(), path(), complete4())) { + for (Graph g : Arrays.asList(star(), triangle(), bowTie(), path(), complete4())) { StructuralHoleAnalyzer a = new StructuralHoleAnalyzer(g); for (StructuralHoleAnalyzer.VertexMetrics vm : a.analyzeAll()) { if (vm.getDegree() > 0) { diff --git a/Gvisual/test/gvisual/SubgraphExtractorTest.java b/Gvisual/test/gvisual/SubgraphExtractorTest.java index e496e44..91ebcd1 100644 --- a/Gvisual/test/gvisual/SubgraphExtractorTest.java +++ b/Gvisual/test/gvisual/SubgraphExtractorTest.java @@ -22,12 +22,12 @@ */ public class SubgraphExtractorTest { - private Graph graph; - private List edges; + private Graph graph; + private List edges; /** Helper to create an edge with type, vertices, weight, and optional timestamps. */ private edge makeEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + edge e = new Edge(type, v1, v2); e.setWeight(weight); return e; } @@ -61,7 +61,7 @@ public void setUp() { for (String v : Arrays.asList("A", "B", "C", "D", "E")) { graph.addVertex(v); } - for (edge e : Arrays.asList(e1, e2, e3, e4, e5, e6)) { + for (Edge e : Arrays.asList(e1, e2, e3, e4, e5, e6)) { graph.addEdge(e, e.getVertex1(), e.getVertex2()); edges.add(e); } @@ -238,14 +238,14 @@ public void testFilterByNodesWithNonExistentNodesIgnoresThem() { @Test public void testFilterByTimeWindow() { // Replace edges with timed ones - List timedEdges = new ArrayList<>(); + List timedEdges = new ArrayList<>(); timedEdges.add(makeTimedEdge("f", "A", "B", 3.0f, 100, 200)); timedEdges.add(makeTimedEdge("c", "B", "C", 1.0f, 300, 400)); timedEdges.add(makeTimedEdge("f", "C", "D", 5.0f, 150, 250)); - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); for (String v : Arrays.asList("A", "B", "C", "D")) g.addVertex(v); - for (edge e : timedEdges) g.addEdge(e, e.getVertex1(), e.getVertex2()); + for (Edge e : timedEdges) g.addEdge(e, e.getVertex1(), e.getVertex2()); SubgraphExtractor.Result result = new SubgraphExtractor(g, timedEdges) .filterByTimeWindow(100, 200) @@ -303,7 +303,7 @@ public void testDensityCalculation() { @Test public void testDensityWithSingleNode() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("X"); SubgraphExtractor.Result result = new SubgraphExtractor(g, Collections.emptyList()) .extract(); @@ -312,7 +312,7 @@ public void testDensityWithSingleNode() { @Test public void testRetentionOnEmptySourceGraph() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("X"); SubgraphExtractor.Result result = new SubgraphExtractor(g, Collections.emptyList()) .extract(); diff --git a/Gvisual/test/gvisual/SubgraphPatternMatcherTest.java b/Gvisual/test/gvisual/SubgraphPatternMatcherTest.java index 8fa9002..f9015f6 100644 --- a/Gvisual/test/gvisual/SubgraphPatternMatcherTest.java +++ b/Gvisual/test/gvisual/SubgraphPatternMatcherTest.java @@ -15,33 +15,33 @@ public class SubgraphPatternMatcherTest { // ── Helpers ───────────────────────────────────────────────── - private Graph emptyGraph() { + private Graph emptyGraph() { return new UndirectedSparseGraph<>(); } - private void addEdge(Graph g, String v1, String v2) { + private void addEdge(Graph g, String v1, String v2) { if (!g.containsVertex(v1)) g.addVertex(v1); if (!g.containsVertex(v2)) g.addVertex(v2); - g.addEdge(new edge(null, v1, v2), v1, v2); + g.addEdge(new Edge(null, v1, v2), v1, v2); } - private void addTypedEdge(Graph g, String v1, String v2, + private void addTypedEdge(Graph g, String v1, String v2, String type) { if (!g.containsVertex(v1)) g.addVertex(v1); if (!g.containsVertex(v2)) g.addVertex(v2); - g.addEdge(new edge(type, v1, v2), v1, v2); + g.addEdge(new Edge(type, v1, v2), v1, v2); } - private Graph makeTriangle(String a, String b, String c) { - Graph g = emptyGraph(); + private Graph makeTriangle(String a, String b, String c) { + Graph g = emptyGraph(); addEdge(g, a, b); addEdge(g, b, c); addEdge(g, a, c); return g; } - private Graph makeK4() { - Graph g = emptyGraph(); + private Graph makeK4() { + Graph g = emptyGraph(); String[] v = {"A", "B", "C", "D"}; for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { @@ -51,8 +51,8 @@ private Graph makeK4() { return g; } - private Graph makePath(String... nodes) { - Graph g = emptyGraph(); + private Graph makePath(String... nodes) { + Graph g = emptyGraph(); for (int i = 0; i < nodes.length - 1; i++) { addEdge(g, nodes[i], nodes[i + 1]); } @@ -74,7 +74,7 @@ public void testNullPattern() { @Test(expected = IllegalArgumentException.class) public void testPatternTooSmall() { - Graph tiny = emptyGraph(); + Graph tiny = emptyGraph(); tiny.addVertex("X"); new SubgraphPatternMatcher.Builder(emptyGraph(), tiny).build(); } @@ -90,7 +90,7 @@ public void testMaxMatchesZero() { @Test public void testNoMatchInEmptyTarget() { - Graph target = emptyGraph(); + Graph target = emptyGraph(); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); SubgraphPatternMatcher.MatchResult r = m.findMatches(); @@ -100,7 +100,7 @@ public void testNoMatchInEmptyTarget() { @Test public void testNoMatchPatternLargerThanTarget() { - Graph target = makePath("A", "B"); + Graph target = makePath("A", "B"); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.squarePattern()).build(); assertEquals(0, m.findMatches().getMatchCount()); @@ -108,7 +108,7 @@ public void testNoMatchPatternLargerThanTarget() { @Test public void testNoTriangleInTree() { - Graph tree = emptyGraph(); + Graph tree = emptyGraph(); addEdge(tree, "A", "B"); addEdge(tree, "A", "C"); addEdge(tree, "B", "D"); @@ -122,7 +122,7 @@ public void testNoTriangleInTree() { @Test public void testSingleTriangleFound() { - Graph target = makeTriangle("A", "B", "C"); + Graph target = makeTriangle("A", "B", "C"); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); SubgraphPatternMatcher.MatchResult r = m.findMatches(); @@ -138,7 +138,7 @@ public void testSingleTriangleFound() { @Test public void testTwoDisjointTriangles() { - Graph target = emptyGraph(); + Graph target = emptyGraph(); addEdge(target, "A", "B"); addEdge(target, "B", "C"); addEdge(target, "A", "C"); @@ -153,7 +153,7 @@ public void testTwoDisjointTriangles() { @Test public void testTrianglesInK4() { - Graph target = makeK4(); + Graph target = makeK4(); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); // K4 contains C(4,3) = 4 triangles @@ -164,8 +164,8 @@ public void testTrianglesInK4() { @Test public void testPathInChain() { - Graph target = makePath("A", "B", "C", "D", "E"); - Graph pattern = SubgraphPatternMatcher.pathPattern(2); + Graph target = makePath("A", "B", "C", "D", "E"); + Graph pattern = SubgraphPatternMatcher.pathPattern(2); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, pattern).build(); SubgraphPatternMatcher.MatchResult r = m.findMatches(); @@ -175,8 +175,8 @@ public void testPathInChain() { @Test public void testPathLength1() { - Graph target = makePath("A", "B", "C"); - Graph pattern = SubgraphPatternMatcher.pathPattern(1); + Graph target = makePath("A", "B", "C"); + Graph pattern = SubgraphPatternMatcher.pathPattern(1); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, pattern).build(); // Two edges: A-B and B-C @@ -187,13 +187,13 @@ public void testPathLength1() { @Test public void testStarInHub() { - Graph target = emptyGraph(); + Graph target = emptyGraph(); addEdge(target, "hub", "A"); addEdge(target, "hub", "B"); addEdge(target, "hub", "C"); addEdge(target, "hub", "D"); - Graph pattern = SubgraphPatternMatcher.starPattern(3); + Graph pattern = SubgraphPatternMatcher.starPattern(3); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, pattern).build(); // 4 leaves choose 3 = 4 star-3 patterns @@ -209,7 +209,7 @@ public void testStarPatternMinLeaves() { @Test public void testSquareFound() { - Graph target = emptyGraph(); + Graph target = emptyGraph(); addEdge(target, "A", "B"); addEdge(target, "B", "C"); addEdge(target, "C", "D"); @@ -222,7 +222,7 @@ public void testSquareFound() { @Test public void testNoSquareInTriangle() { - Graph target = makeTriangle("A", "B", "C"); + Graph target = makeTriangle("A", "B", "C"); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.squarePattern()).build(); assertEquals(0, m.findMatches().getMatchCount()); @@ -237,7 +237,7 @@ public void testDiamondInK4() { // But dedup by node set: all cover {A,B,C,D} = only 1 unique set. // Actually no — diamond is a specific subgraph structure, not just // a node set. With dedup by node set, K4 yields 1 match. - Graph target = makeK4(); + Graph target = makeK4(); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.diamondPattern()).build(); // All 4 nodes form a single set → 1 unique match @@ -246,7 +246,7 @@ public void testDiamondInK4() { @Test public void testDiamondPattern() { - Graph p = SubgraphPatternMatcher.diamondPattern(); + Graph p = SubgraphPatternMatcher.diamondPattern(); assertEquals(4, p.getVertexCount()); assertEquals(5, p.getEdgeCount()); } @@ -255,14 +255,14 @@ public void testDiamondPattern() { @Test public void testBowtiePattern() { - Graph p = SubgraphPatternMatcher.bowtiePattern(); + Graph p = SubgraphPatternMatcher.bowtiePattern(); assertEquals(5, p.getVertexCount()); assertEquals(6, p.getEdgeCount()); } @Test public void testBowtieFound() { - Graph target = emptyGraph(); + Graph target = emptyGraph(); // Two triangles sharing node C addEdge(target, "A", "B"); addEdge(target, "B", "C"); @@ -282,7 +282,7 @@ public void testBowtieFound() { @Test public void testCompletePattern() { - Graph p = SubgraphPatternMatcher.completePattern(4); + Graph p = SubgraphPatternMatcher.completePattern(4); assertEquals(4, p.getVertexCount()); assertEquals(6, p.getEdgeCount()); } @@ -294,7 +294,7 @@ public void testCompletePatternMinNodes() { @Test public void testK4InK5() { - Graph k5 = emptyGraph(); + Graph k5 = emptyGraph(); String[] v = {"A", "B", "C", "D", "E"}; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { @@ -311,14 +311,14 @@ public void testK4InK5() { @Test public void testHousePattern() { - Graph p = SubgraphPatternMatcher.housePattern(); + Graph p = SubgraphPatternMatcher.housePattern(); assertEquals(5, p.getVertexCount()); assertEquals(6, p.getEdgeCount()); } @Test public void testHouseFound() { - Graph target = emptyGraph(); + Graph target = emptyGraph(); addEdge(target, "A", "B"); addEdge(target, "B", "C"); addEdge(target, "C", "D"); @@ -335,7 +335,7 @@ public void testHouseFound() { @Test public void testMaxMatchesLimit() { - Graph target = makeK4(); + Graph target = makeK4(); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()) .maxMatches(2).build(); @@ -350,13 +350,13 @@ public void testMaxMatchesLimit() { public void testDegreeConstrainedReducesMatches() { // Star hub has degree 4, pattern hub has degree 3 // With degree constraint, hub must have degree >= 3 - Graph target = emptyGraph(); + Graph target = emptyGraph(); addEdge(target, "H", "A"); addEdge(target, "H", "B"); addEdge(target, "H", "C"); addEdge(target, "H", "D"); - Graph pattern = SubgraphPatternMatcher.starPattern(3); + Graph pattern = SubgraphPatternMatcher.starPattern(3); // Without degree constraint SubgraphPatternMatcher m1 = new SubgraphPatternMatcher.Builder( @@ -376,7 +376,7 @@ public void testDegreeConstrainedReducesMatches() { @Test public void testEdgeTypeFilter() { - Graph target = emptyGraph(); + Graph target = emptyGraph(); addTypedEdge(target, "A", "B", "friend"); addTypedEdge(target, "B", "C", "friend"); addTypedEdge(target, "A", "C", "colleague"); @@ -390,7 +390,7 @@ public void testEdgeTypeFilter() { @Test public void testEdgeTypeFilterFindsMatch() { - Graph target = emptyGraph(); + Graph target = emptyGraph(); addTypedEdge(target, "A", "B", "friend"); addTypedEdge(target, "B", "C", "friend"); addTypedEdge(target, "A", "C", "friend"); @@ -463,7 +463,7 @@ public void testMatchToString() { @Test public void testCoverage() { - Graph target = emptyGraph(); + Graph target = emptyGraph(); addEdge(target, "A", "B"); addEdge(target, "B", "C"); addEdge(target, "A", "C"); @@ -479,7 +479,7 @@ public void testCoverage() { @Test public void testNodeParticipation() { - Graph target = makeK4(); + Graph target = makeK4(); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); SubgraphPatternMatcher.MatchResult r = m.findMatches(); @@ -492,7 +492,7 @@ public void testNodeParticipation() { @Test public void testTopParticipants() { - Graph target = makeK4(); + Graph target = makeK4(); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); List> top = @@ -503,7 +503,7 @@ public void testTopParticipants() { @Test public void testAverageOverlapNoMatches() { - Graph target = makePath("A", "B", "C"); + Graph target = makePath("A", "B", "C"); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); assertEquals(0, m.findMatches().getAverageOverlap(), 0.001); @@ -511,7 +511,7 @@ public void testAverageOverlapNoMatches() { @Test public void testAverageOverlapOneMatch() { - Graph target = makeTriangle("A", "B", "C"); + Graph target = makeTriangle("A", "B", "C"); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); assertEquals(0, m.findMatches().getAverageOverlap(), 0.001); @@ -519,7 +519,7 @@ public void testAverageOverlapOneMatch() { @Test public void testAverageOverlapMultipleMatches() { - Graph target = makeK4(); + Graph target = makeK4(); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); SubgraphPatternMatcher.MatchResult r = m.findMatches(); @@ -531,7 +531,7 @@ public void testAverageOverlapMultipleMatches() { @Test public void testReport() { - Graph target = makeK4(); + Graph target = makeK4(); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); String report = m.findMatches().generateReport(); @@ -544,7 +544,7 @@ public void testReport() { @Test public void testReportEmpty() { - Graph target = makePath("A", "B"); + Graph target = makePath("A", "B"); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, SubgraphPatternMatcher.trianglePattern()).build(); String report = m.findMatches().generateReport(); @@ -556,14 +556,14 @@ public void testReportEmpty() { @Test public void testCustomPattern() { // Custom pattern: 4-clique with one pendant (tail) - Graph pattern = emptyGraph(); + Graph pattern = emptyGraph(); addEdge(pattern, "A", "B"); addEdge(pattern, "A", "C"); addEdge(pattern, "B", "C"); addEdge(pattern, "C", "D"); // pendant // Target: triangle + pendant - Graph target = emptyGraph(); + Graph target = emptyGraph(); addEdge(target, "X", "Y"); addEdge(target, "Y", "Z"); addEdge(target, "X", "Z"); @@ -580,9 +580,9 @@ public void testCustomPattern() { @Test public void testDeduplicated() { // Path P0-P1 can match A-B in two orientations but should dedup - Graph target = emptyGraph(); + Graph target = emptyGraph(); addEdge(target, "A", "B"); - Graph pattern = SubgraphPatternMatcher.pathPattern(1); + Graph pattern = SubgraphPatternMatcher.pathPattern(1); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( target, pattern).build(); assertEquals(1, m.findMatches().getMatchCount()); @@ -592,7 +592,7 @@ public void testDeduplicated() { @Test public void testIsolatedNodesIgnored() { - Graph target = makeTriangle("A", "B", "C"); + Graph target = makeTriangle("A", "B", "C"); target.addVertex("D"); target.addVertex("E"); SubgraphPatternMatcher m = new SubgraphPatternMatcher.Builder( diff --git a/Gvisual/test/gvisual/SvgExporterTest.java b/Gvisual/test/gvisual/SvgExporterTest.java index 8e54eb6..0cfa7f4 100644 --- a/Gvisual/test/gvisual/SvgExporterTest.java +++ b/Gvisual/test/gvisual/SvgExporterTest.java @@ -12,7 +12,7 @@ */ public class SvgExporterTest { - private Graph graph; + private Graph graph; @Before public void setUp() { @@ -22,19 +22,19 @@ public void setUp() { graph.addVertex("C"); graph.addVertex("D"); - edge e1 = new edge("f", "A", "B"); + edge e1 = new Edge("f", "A", "B"); e1.setWeight(1.5f); graph.addEdge(e1, "A", "B"); - edge e2 = new edge("c", "B", "C"); + edge e2 = new Edge("c", "B", "C"); e2.setWeight(2.0f); graph.addEdge(e2, "B", "C"); - edge e3 = new edge("s", "A", "C"); + edge e3 = new Edge("s", "A", "C"); e3.setWeight(0.5f); graph.addEdge(e3, "A", "C"); - edge e4 = new edge("sg", "C", "D"); + edge e4 = new Edge("sg", "C", "D"); e4.setWeight(3.0f); graph.addEdge(e4, "C", "D"); } @@ -143,7 +143,7 @@ public void darkThemeIsDefault() { @Test public void emptyGraphProducesSvg() { - Graph empty = new UndirectedSparseGraph<>(); + Graph empty = new UndirectedSparseGraph<>(); SvgExporter exporter = new SvgExporter(empty); String svg = exporter.exportToString(); assertTrue(svg.contains(" single = new UndirectedSparseGraph<>(); + Graph single = new UndirectedSparseGraph<>(); single.addVertex("X"); SvgExporter exporter = new SvgExporter(single); String svg = exporter.exportToString(); @@ -180,10 +180,10 @@ public void customTypeColor() { @Test public void xmlSpecialCharsEscaped() { - Graph g = new UndirectedSparseGraph<>(); + Graph g = new UndirectedSparseGraph<>(); g.addVertex("