From 01222c17291b0b94996555ab3e604f93a7f7a25d Mon Sep 17 00:00:00 2001 From: Saurav Bhattacharya Date: Sun, 22 Mar 2026 07:19:08 -0700 Subject: [PATCH] refactor: rename edge class to Edge (Java naming convention) Rename the edge class to Edge to follow Java PascalCase naming conventions. Update all references across 150+ source and test files. Fixes #89 --- Gvisual/src/app/Network.java | 2 +- .../src/gvisual/AdjacencyMatrixHeatmap.java | 30 +-- .../gvisual/ArticulationPanelController.java | 10 +- .../gvisual/ArticulationPointAnalyzer.java | 50 ++--- Gvisual/src/gvisual/BipartiteAnalyzer.java | 14 +- .../gvisual/CentralityPanelController.java | 6 +- .../src/gvisual/CentralityRadarExporter.java | 4 +- Gvisual/src/gvisual/ChordalGraphAnalyzer.java | 32 +-- Gvisual/src/gvisual/CircularLayout.java | 24 +-- Gvisual/src/gvisual/CliqueAnalyzer.java | 4 +- Gvisual/src/gvisual/CommunityDetector.java | 26 +-- .../gvisual/CommunityEvolutionTracker.java | 10 +- .../src/gvisual/CommunityPanelController.java | 4 +- Gvisual/src/gvisual/CsvReportExporter.java | 12 +- Gvisual/src/gvisual/CycleAnalyzer.java | 28 +-- .../gvisual/DegreeDistributionAnalyzer.java | 8 +- .../src/gvisual/DominatingSetAnalyzer.java | 6 +- Gvisual/src/gvisual/DotExporter.java | 24 +-- Gvisual/src/gvisual/{edge.java => Edge.java} | 6 +- .../src/gvisual/EdgePersistenceAnalyzer.java | 38 ++-- Gvisual/src/gvisual/EdgeType.java | 10 +- Gvisual/src/gvisual/EgoPanelController.java | 16 +- Gvisual/src/gvisual/EulerianPathAnalyzer.java | 52 ++--- Gvisual/src/gvisual/ExportActions.java | 2 +- Gvisual/src/gvisual/FamousGraphLibrary.java | 64 +++--- .../gvisual/FeedbackVertexSetAnalyzer.java | 18 +- Gvisual/src/gvisual/ForceDirectedLayout.java | 46 ++-- Gvisual/src/gvisual/GexfExporter.java | 26 +-- .../src/gvisual/GraphAlgorithmAnimator.java | 46 ++-- .../src/gvisual/GraphAnnotationManager.java | 16 +- Gvisual/src/gvisual/GraphAnomalyDetector.java | 14 +- Gvisual/src/gvisual/GraphAsciiRenderer.java | 18 +- Gvisual/src/gvisual/GraphBenchmarkSuite.java | 24 +-- .../gvisual/GraphCentralityCorrelator.java | 4 +- .../gvisual/GraphClusterQualityAnalyzer.java | 22 +- .../src/gvisual/GraphColoringAnalyzer.java | 20 +- .../src/gvisual/GraphComplementAnalyzer.java | 34 +-- Gvisual/src/gvisual/GraphCompressor.java | 32 +-- .../src/gvisual/GraphDiameterAnalyzer.java | 6 +- Gvisual/src/gvisual/GraphDiffAnalyzer.java | 20 +- .../src/gvisual/GraphDiffHtmlExporter.java | 6 +- .../gvisual/GraphDistanceDistribution.java | 6 +- Gvisual/src/gvisual/GraphEntropyAnalyzer.java | 16 +- Gvisual/src/gvisual/GraphFileParser.java | 44 ++-- Gvisual/src/gvisual/GraphGenerator.java | 50 ++--- Gvisual/src/gvisual/GraphHealthChecker.java | 32 +-- .../src/gvisual/GraphIsomorphismAnalyzer.java | 22 +- Gvisual/src/gvisual/GraphLayoutComparer.java | 8 +- Gvisual/src/gvisual/GraphMLExporter.java | 42 ++-- Gvisual/src/gvisual/GraphMerger.java | 98 ++++----- Gvisual/src/gvisual/GraphMinorAnalyzer.java | 90 ++++---- .../gvisual/GraphNeighborhoodAnalyzer.java | 14 +- Gvisual/src/gvisual/GraphNetworkProfiler.java | 8 +- Gvisual/src/gvisual/GraphPartitioner.java | 20 +- Gvisual/src/gvisual/GraphPathExplorer.java | 12 +- .../src/gvisual/GraphPathExplorerTest.java | 38 ++-- .../src/gvisual/GraphProductCalculator.java | 46 ++-- Gvisual/src/gvisual/GraphQueryEngine.java | 46 ++-- Gvisual/src/gvisual/GraphRenderers.java | 34 +-- .../src/gvisual/GraphResilienceAnalyzer.java | 22 +- Gvisual/src/gvisual/GraphSampler.java | 46 ++-- .../src/gvisual/GraphSimilarityAnalyzer.java | 14 +- .../gvisual/GraphSparsificationAnalyzer.java | 118 +++++------ Gvisual/src/gvisual/GraphStats.java | 32 +-- Gvisual/src/gvisual/GraphSummarizer.java | 36 ++-- .../src/gvisual/GraphSymmetryAnalyzer.java | 24 +-- .../src/gvisual/GraphTimelineExporter.java | 8 +- Gvisual/src/gvisual/GraphUtils.java | 76 +++---- Gvisual/src/gvisual/GrowthRateAnalyzer.java | 16 +- Gvisual/src/gvisual/HierarchicalLayout.java | 32 +-- .../src/gvisual/IndependentSetAnalyzer.java | 18 +- .../src/gvisual/InfluenceSpreadSimulator.java | 20 +- .../src/gvisual/InteractiveHtmlExporter.java | 12 +- Gvisual/src/gvisual/JsonGraphExporter.java | 16 +- Gvisual/src/gvisual/KCoreDecomposition.java | 10 +- Gvisual/src/gvisual/KTrussAnalyzer.java | 114 +++++----- Gvisual/src/gvisual/LaplacianBuilder.java | 12 +- Gvisual/src/gvisual/LineGraphAnalyzer.java | 42 ++-- .../src/gvisual/LinkPredictionAnalyzer.java | 8 +- .../src/gvisual/LouvainCommunityDetector.java | 14 +- Gvisual/src/gvisual/MSTPanelController.java | 12 +- Gvisual/src/gvisual/Main.java | 80 +++---- Gvisual/src/gvisual/MaxCutAnalyzer.java | 30 +-- .../src/gvisual/MetricDimensionAnalyzer.java | 4 +- Gvisual/src/gvisual/MinimumSpanningTree.java | 80 +++---- Gvisual/src/gvisual/MotifAnalyzer.java | 4 +- Gvisual/src/gvisual/NetworkFlowAnalyzer.java | 62 +++--- .../src/gvisual/NetworkReportGenerator.java | 36 ++-- .../src/gvisual/NetworkRoleClassifier.java | 8 +- .../src/gvisual/NodeCentralityAnalyzer.java | 10 +- .../src/gvisual/NodeSimilarityAnalyzer.java | 4 +- Gvisual/src/gvisual/PageRankAnalyzer.java | 16 +- Gvisual/src/gvisual/PathPanelController.java | 20 +- Gvisual/src/gvisual/PlanarGraphAnalyzer.java | 42 ++-- .../gvisual/ResiliencePanelController.java | 6 +- Gvisual/src/gvisual/RichClubAnalyzer.java | 16 +- Gvisual/src/gvisual/ShortestPathFinder.java | 48 ++--- Gvisual/src/gvisual/SignedGraphAnalyzer.java | 96 ++++----- Gvisual/src/gvisual/SmallWorldAnalyzer.java | 4 +- Gvisual/src/gvisual/SpectralAnalyzer.java | 4 +- Gvisual/src/gvisual/SteinerTreeAnalyzer.java | 14 +- .../StronglyConnectedComponentsAnalyzer.java | 32 +-- .../src/gvisual/StructuralHoleAnalyzer.java | 10 +- Gvisual/src/gvisual/SubgraphExtractor.java | 52 ++--- .../src/gvisual/SubgraphPatternMatcher.java | 110 +++++----- Gvisual/src/gvisual/SvgExporter.java | 26 +-- Gvisual/src/gvisual/TemporalGraph.java | 34 +-- Gvisual/src/gvisual/ToolbarBuilder.java | 14 +- .../src/gvisual/TopologicalSortAnalyzer.java | 30 +-- Gvisual/src/gvisual/TournamentAnalyzer.java | 14 +- Gvisual/src/gvisual/TreeAnalyzer.java | 8 +- Gvisual/src/gvisual/TreewidthAnalyzer.java | 12 +- .../gvisual/VertexConnectivityAnalyzer.java | 72 +++---- Gvisual/src/gvisual/VertexCoverAnalyzer.java | 24 +-- .../src/test/GraphTimelineExporterTest.java | 8 +- .../src/test/gvisual/CycleAnalyzerTest.java | 68 +++--- .../gvisual/GraphComplementAnalyzerTest.java | 32 +-- .../src/test/gvisual/GraphCompressorTest.java | 4 +- Gvisual/src/test/gvisual/GraphMergerTest.java | 16 +- .../gvisual/GraphProductCalculatorTest.java | 48 ++--- .../test/gvisual/PageRankAnalyzerTest.java | 14 +- .../ArticulationPointAnalyzerTest.java | 12 +- .../test/gvisual/BipartiteAnalyzerTest.java | 18 +- .../gvisual/ChordalGraphAnalyzerTest.java | 32 +-- Gvisual/test/gvisual/CircularLayoutTest.java | 18 +- Gvisual/test/gvisual/CliqueAnalyzerTest.java | 26 +-- .../test/gvisual/CommunityDetectorTest.java | 84 ++++---- .../CommunityEvolutionTrackerTest.java | 90 ++++---- .../test/gvisual/CsvReportExporterTest.java | 78 +++---- Gvisual/test/gvisual/CycleAnalyzerTest.java | 108 +++++----- .../DegreeDistributionAnalyzerTest.java | 12 +- .../gvisual/DominatingSetAnalyzerTest.java | 8 +- Gvisual/test/gvisual/DotExporterTest.java | 24 +-- .../gvisual/EdgePersistenceAnalyzerTest.java | 38 ++-- Gvisual/test/gvisual/EdgeTest.java | 40 ++-- .../gvisual/EulerianPathAnalyzerTest.java | 88 ++++---- .../FeedbackVertexSetAnalyzerTest.java | 32 +-- .../test/gvisual/ForceDirectedLayoutTest.java | 18 +- Gvisual/test/gvisual/GexfExporterTest.java | 18 +- .../gvisual/GraphAlgorithmAnimatorTest.java | 34 +-- .../gvisual/GraphAnnotationManagerTest.java | 16 +- .../gvisual/GraphAnomalyDetectorTest.java | 48 ++--- .../test/gvisual/GraphAsciiRendererTest.java | 26 +-- .../test/gvisual/GraphBenchmarkSuiteTest.java | 10 +- .../GraphCentralityCorrelatorTest.java | 8 +- .../GraphClusterQualityAnalyzerTest.java | 8 +- .../gvisual/GraphColoringAnalyzerTest.java | 8 +- .../gvisual/GraphDiameterAnalyzerTest.java | 30 +-- .../test/gvisual/GraphDiffAnalyzerTest.java | 22 +- .../GraphDistanceDistributionTest.java | 52 ++--- .../gvisual/GraphEntropyAnalyzerTest.java | 80 +++---- Gvisual/test/gvisual/GraphGeneratorTest.java | 20 +- .../gvisual/GraphIsomorphismAnalyzerTest.java | 122 +++++------ Gvisual/test/gvisual/GraphMLExporterTest.java | 66 +++--- Gvisual/test/gvisual/GraphMergerTest.java | 38 ++-- .../test/gvisual/GraphMinorAnalyzerTest.java | 76 +++---- .../GraphNeighborhoodAnalyzerTest.java | 8 +- .../gvisual/GraphNetworkProfilerTest.java | 38 ++-- .../test/gvisual/GraphPartitionerTest.java | 12 +- .../test/gvisual/GraphPathExplorerTest.java | 10 +- .../test/gvisual/GraphQueryEngineTest.java | 28 +-- .../gvisual/GraphResilienceAnalyzerTest.java | 28 +-- Gvisual/test/gvisual/GraphSamplerTest.java | 10 +- .../gvisual/GraphSimilarityAnalyzerTest.java | 146 ++++++------- .../GraphSparsificationAnalyzerTest.java | 70 +++---- Gvisual/test/gvisual/GraphStatsTest.java | 198 +++++++++--------- Gvisual/test/gvisual/GraphSummarizerTest.java | 70 +++---- .../gvisual/GraphSymmetryAnalyzerTest.java | 18 +- Gvisual/test/gvisual/GraphUtilsTest.java | 52 ++--- .../test/gvisual/GrowthRateAnalyzerTest.java | 154 +++++++------- .../test/gvisual/HamiltonianAnalyzerTest.java | 8 +- .../test/gvisual/HierarchicalLayoutTest.java | 80 +++---- .../gvisual/IndependentSetAnalyzerTest.java | 90 ++++---- .../gvisual/InfluenceSpreadSimulatorTest.java | 42 ++-- .../gvisual/InteractiveHtmlExporterTest.java | 14 +- .../test/gvisual/JsonGraphExporterTest.java | 50 ++--- .../test/gvisual/KCoreDecompositionTest.java | 10 +- Gvisual/test/gvisual/KTrussAnalyzerTest.java | 22 +- .../test/gvisual/LaplacianBuilderTest.java | 6 +- .../test/gvisual/LineGraphAnalyzerTest.java | 36 ++-- .../gvisual/LinkPredictionAnalyzerTest.java | 152 +++++++------- .../gvisual/LouvainCommunityDetectorTest.java | 8 +- Gvisual/test/gvisual/MaxCutAnalyzerTest.java | 10 +- .../gvisual/MetricDimensionAnalyzerTest.java | 58 ++--- .../test/gvisual/MinimumSpanningTreeTest.java | 142 ++++++------- Gvisual/test/gvisual/MotifAnalyzerTest.java | 8 +- .../test/gvisual/NetworkFlowAnalyzerTest.java | 32 +-- .../gvisual/NetworkReportGeneratorTest.java | 34 +-- .../gvisual/NetworkRoleClassifierTest.java | 72 +++---- .../gvisual/NodeCentralityAnalyzerTest.java | 12 +- .../gvisual/NodeSimilarityAnalyzerTest.java | 6 +- .../test/gvisual/PageRankAnalyzerTest.java | 10 +- .../test/gvisual/PlanarGraphAnalyzerTest.java | 102 ++++----- .../test/gvisual/RandomWalkAnalyzerTest.java | 6 +- .../test/gvisual/RichClubAnalyzerTest.java | 44 ++-- .../test/gvisual/ShortestPathFinderTest.java | 20 +- .../test/gvisual/SignedGraphAnalyzerTest.java | 54 ++--- .../test/gvisual/SmallWorldAnalyzerTest.java | 4 +- .../test/gvisual/SpectralAnalyzerTest.java | 28 +-- .../test/gvisual/SteinerTreeAnalyzerTest.java | 98 ++++----- ...ronglyConnectedComponentsAnalyzerTest.java | 80 +++---- .../gvisual/StructuralHoleAnalyzerTest.java | 88 ++++---- .../test/gvisual/SubgraphExtractorTest.java | 46 ++-- .../gvisual/SubgraphPatternMatcherTest.java | 106 +++++----- Gvisual/test/gvisual/SvgExporterTest.java | 20 +- Gvisual/test/gvisual/TemporalGraphTest.java | 60 +++--- .../gvisual/TopologicalSortAnalyzerTest.java | 105 +++++----- .../test/gvisual/TournamentAnalyzerTest.java | 16 +- Gvisual/test/gvisual/TreeAnalyzerTest.java | 32 +-- .../test/gvisual/TreewidthAnalyzerTest.java | 6 +- .../VertexConnectivityAnalyzerTest.java | 106 +++++----- .../test/gvisual/VertexCoverAnalyzerTest.java | 10 +- 212 files changed, 3778 insertions(+), 3779 deletions(-) rename Gvisual/src/gvisual/{edge.java => Edge.java} (97%) diff --git a/Gvisual/src/app/Network.java b/Gvisual/src/app/Network.java index def315e..9626040 100644 --- a/Gvisual/src/app/Network.java +++ b/Gvisual/src/app/Network.java @@ -16,7 +16,7 @@ public class Network { /** * - * Connects to database and writes out the edge-list from the meeting DB table, forming edges of kind: + * Connects to database and writes out the Edge-list from the meeting DB table, forming edges of kind: * friends, classmates, study-groups, strangers and familiar strangers (depending upon parameters). * *

The output path is validated to prevent directory traversal — diff --git a/Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java b/Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java index 8ce1273..c23e5c0 100644 --- a/Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java +++ b/Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java @@ -13,22 +13,22 @@ /** * Adjacency matrix heatmap visualization for graphs. * Displays the graph as a colored matrix where cell intensity represents - * edge weight/presence, with edge-type color coding. + * Edge weight/presence, with Edge-type color coding. * * Features: - * - Color-coded cells by edge type (friend, classmate, familiar stranger, etc.) + * - Color-coded cells by Edge type (friend, classmate, familiar stranger, etc.) * - Zoom and pan controls * - Node reordering by degree, name, or community - * - Tooltip on hover showing node pair and edge details + * - Tooltip on hover showing node pair and Edge details * - Export to PNG * * @author zalenix */ public class AdjacencyMatrixHeatmap extends JPanel { - private final Graph 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,14 +192,14 @@ 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); + Edge ed = rowMap.get(hoveredCol); String type = getEdgeTypeName(ed.getType()); String weight = ed.getWeight() != 0 ? ", weight: " + ed.getWeight() : ""; return hoveredRow + " ↔ " + hoveredCol + " [" + type + weight + "]"; } - return hoveredRow + " ↔ " + hoveredCol + " (no edge)"; + return hoveredRow + " ↔ " + hoveredCol + " (no Edge)"; } return null; } @@ -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,9 +269,9 @@ protected void paintComponent(Graphics g2) { int brightness = Math.min(255, 40 + deg * 15); g.setColor(new Color(brightness, brightness, brightness)); } else { - Map rowMap = adjacency.get(nodeR); + Map rowMap = adjacency.get(nodeR); if (rowMap != null && rowMap.containsKey(nodeC)) { - edge e = rowMap.get(nodeC); + Edge e = rowMap.get(nodeC); Color base = getEdgeColor(e); float alpha = e.getWeight() > 0 ? Math.min(1f, 0.4f + e.getWeight() * 0.1f) : 0.85f; g.setColor(new Color(base.getRed(), base.getGreen(), base.getBlue(), @@ -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..790d8bd 100644 --- a/Gvisual/src/gvisual/ArticulationPointAnalyzer.java +++ b/Gvisual/src/gvisual/ArticulationPointAnalyzer.java @@ -10,7 +10,7 @@ * *

An articulation point is a vertex whose removal disconnects * the graph (or increases its number of connected components). A - * bridge is an edge whose removal disconnects the graph.

+ * bridge is an Edge whose removal disconnects the graph.

* *

These are critical elements for network reliability analysis:

* * *

Features

@@ -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

    @@ -79,11 +79,11 @@ public enum Ordering { COMMUNITY, /** BFS traversal from the highest-degree node. */ BFS, - /** Greedy heuristic to minimize edge crossings. */ + /** Greedy heuristic to minimize Edge crossings. */ 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)) { @@ -410,7 +410,7 @@ public List getOrderedVertices() { return Collections.unmodifiableList(orderedVertices); } - /** Returns edge crossing count. */ + /** Returns Edge crossing count. */ public int getEdgeCrossings() { ensureComputed(); return edgeCrossings; @@ -472,7 +472,7 @@ public String toSvg() { + "viewBox=\"0 0 %.0f %.0f\">\n", width, height, width, height)); svg.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; sb.append(String.format( - " \n", p1[0], p1[1], p2[0], p2[1])); } @@ -701,10 +701,10 @@ public LayoutQuality(int edgeCrossings, double edgeLengthCV, this.converged = converged; } - /** Number of edge crossings in the layout. */ + /** Number of Edge crossings in the layout. */ public int getEdgeCrossings() { return edgeCrossings; } - /** Coefficient of variation of edge lengths (0 = perfectly uniform). */ + /** Coefficient of variation of Edge lengths (0 = perfectly uniform). */ public double getEdgeLengthCV() { return edgeLengthCV; } /** Minimum angle between adjacent edges at any vertex (degrees). */ diff --git a/Gvisual/src/gvisual/GexfExporter.java b/Gvisual/src/gvisual/GexfExporter.java index 5441ad1..655069d 100644 --- a/Gvisual/src/gvisual/GexfExporter.java +++ b/Gvisual/src/gvisual/GexfExporter.java @@ -19,7 +19,7 @@ *
      *
    • Node attributes: degree, label
    • *
    • Edge attributes: type, weight, label
    • - *
    • Dynamic mode with temporal edge spells when timestamps are present
    • + *
    • Dynamic mode with temporal Edge spells when timestamps are present
    • *
    • Edge-type → color mapping via viz:color elements
    • *
    • Node sizing by degree via viz:size elements
    • *
    • Creator and description metadata
    • @@ -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. */ @@ -149,7 +149,7 @@ public String exportToString() { sb.append(" \n"); sb.append(" \n"); sb.append(" \n"); - sb.append(" \n"); + sb.append(" \n"); sb.append(" \n"); sb.append(" \n"); sb.append(" \n"); @@ -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 @@ -192,7 +192,7 @@ public String exportToString() { continue; } - sb.append(" \n"); @@ -205,7 +205,7 @@ public String exportToString() { sb.append(" \n"); sb.append(" \n"); - // Viz colour by edge type + // Viz colour by Edge type if (includeVizData && type.length() > 0) { int[] rgb = TYPE_COLORS.getOrDefault(type, new int[]{128, 128, 128}); sb.append(" \n"); } - sb.append(" \n"); + sb.append(" \n"); } sb.append(" \n"); @@ -236,10 +236,10 @@ public String exportToString() { } /** - * Checks whether any edge in the graph carries temporal data. + * 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..71a9aaa 100644 --- a/Gvisual/src/gvisual/GraphAlgorithmAnimator.java +++ b/Gvisual/src/gvisual/GraphAlgorithmAnimator.java @@ -24,7 +24,7 @@ * *

      Usage:

      *
      - *   Graph<String, edge> g = ...;
      + *   Graph<String, Edge> g = ...;
        *   GraphAlgorithmAnimator animator = new GraphAlgorithmAnimator(g);
        *   List<AnimationFrame> frames = animator.animateBFS("A");
        *   for (AnimationFrame f : frames) {
      @@ -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;
      @@ -46,7 +46,7 @@ public class GraphAlgorithmAnimator {
       
           // ── Color palette ─────────────────────────────────────────────
       
      -    /** Node/edge in default unvisited state. */
      +    /** Node/Edge in default unvisited state. */
           private static final String COLOR_UNVISITED = "#cbd5e1";
           /** Node currently being processed. */
           private static final String COLOR_CURRENT = "#ef4444";
      @@ -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;
      @@ -222,7 +222,7 @@ public List animateBFS(String source) {
                   Collections.sort(neighbors);
       
                   for (String neighbor : neighbors) {
      -                edge e = findEdge(current, neighbor);
      +                Edge e = findEdge(current, neighbor);
                       if (e != null) {
                           s.edgeColors.put(edgeKey(e), COLOR_ACTIVE_EDGE);
                       }
      @@ -307,7 +307,7 @@ private void dfsRecurse(String current, Set visited,
       
               for (String neighbor : neighbors) {
                   if (!visited.contains(neighbor)) {
      -                edge e = findEdge(current, neighbor);
      +                Edge e = findEdge(current, neighbor);
                       if (e != null) {
                           s.edgeColors.put(edgeKey(e), COLOR_TREE_EDGE);
                       }
      @@ -366,9 +366,9 @@ public List animateDijkstra(String source) {
                   finalized.add(u);
                   s.nodeColors.put(u, COLOR_CURRENT);
       
      -            // Highlight the tree edge to this node
      +            // Highlight the tree Edge to this node
                   if (prev.containsKey(u)) {
      -                edge pe = findEdge(prev.get(u), u);
      +                Edge pe = findEdge(prev.get(u), u);
                       if (pe != null) s.edgeColors.put(edgeKey(pe), COLOR_TREE_EDGE);
                   }
       
      @@ -380,7 +380,7 @@ public List animateDijkstra(String source) {
                   for (String v : neighbors) {
                       if (finalized.contains(v)) continue;
       
      -                edge e = findEdge(u, v);
      +                Edge e = findEdge(u, v);
                       double weight = (e != null) ? Math.max(e.getWeight(), 0.001) : 1.0;
                       double alt = dist.get(u) + weight;
       
      @@ -427,8 +427,8 @@ public List animateKruskal() {
               Map edgeLabelOverrides = new LinkedHashMap<>();
       
               // Sort edges by weight
      -        List sortedEdges = new ArrayList<>(graph.getEdges());
      -        sortedEdges.sort(Comparator.comparingDouble(edge::getWeight));
      +        List sortedEdges = new ArrayList<>(graph.getEdges());
      +        sortedEdges.sort(Comparator.comparingDouble(Edge::getWeight));
       
               // Union-Find
               Map parent = new LinkedHashMap<>();
      @@ -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);
      @@ -468,13 +468,13 @@ public List animateKruskal() {
                       totalWeight += e.getWeight();
       
                       frames.add(new AnimationFrame(step, "Kruskal",
      -                        "Add edge " + u + "—" + v +
      +                        "Add Edge " + u + "—" + v +
                                       " (w=" + String.format("%.1f", e.getWeight()) +
                                       ") — " + treeEdges + " tree edges",
                               s.nodeColors, s.edgeColors, s.nodeLabels, edgeLabelOverrides));
                   } else {
                       frames.add(new AnimationFrame(step, "Kruskal",
      -                        "Skip edge " + u + "—" + v +
      +                        "Skip Edge " + u + "—" + v +
                                       " (would create cycle)",
                               s.nodeColors, s.edgeColors, s.nodeLabels, edgeLabelOverrides));
                       s.edgeColors.put(ek, COLOR_UNVISITED);
      @@ -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,15 +789,15 @@ 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();
               return (a.compareTo(b) <= 0) ? a + "~~" + b : b + "~~" + a;
           }
       
      -    private edge findEdge(String u, String v) {
      -        edge e = graph.findEdge(u, v);
      +    private Edge findEdge(String u, String v) {
      +        Edge e = graph.findEdge(u, v);
               if (e == null) e = graph.findEdge(v, u);
               return e;
           }
      @@ -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/GraphAnnotationManager.java b/Gvisual/src/gvisual/GraphAnnotationManager.java
      index 0c8841b..7434c78 100644
      --- a/Gvisual/src/gvisual/GraphAnnotationManager.java
      +++ b/Gvisual/src/gvisual/GraphAnnotationManager.java
      @@ -17,7 +17,7 @@
       public class GraphAnnotationManager {
       
           /**
      -     * Represents an annotation on a graph element (node or edge).
      +     * Represents an annotation on a graph element (node or Edge).
            */
           public static class Annotation {
               private final String elementId;
      @@ -142,7 +142,7 @@ public boolean removeNodeAnnotation(String nodeId) {
           // --- Edge annotations ---
       
           /**
      -     * Build a canonical edge ID from two vertices.
      +     * Build a canonical Edge ID from two vertices.
            */
           public static String edgeKey(String v1, String v2) {
               if (v1.compareTo(v2) <= 0) return v1 + "--" + v2;
      @@ -150,7 +150,7 @@ public static String edgeKey(String v1, String v2) {
           }
       
           /**
      -     * Annotate an edge by its endpoint vertices.
      +     * Annotate an Edge by its endpoint vertices.
            */
           public Annotation annotateEdge(String v1, String v2) {
               String key = edgeKey(v1, v2);
      @@ -159,14 +159,14 @@ public Annotation annotateEdge(String v1, String v2) {
           }
       
           /**
      -     * Get annotation for an edge, or null if none exists.
      +     * Get annotation for an Edge, or null if none exists.
            */
           public Annotation getEdgeAnnotation(String v1, String v2) {
               return edgeAnnotations.get(edgeKey(v1, v2));
           }
       
           /**
      -     * Remove annotation from an edge.
      +     * Remove annotation from an Edge.
            */
           public boolean removeEdgeAnnotation(String v1, String v2) {
               return edgeAnnotations.remove(edgeKey(v1, v2)) != null;
      @@ -201,7 +201,7 @@ public int bulkColorNodes(Collection nodeIds, String color) {
           // --- Search & filtering ---
       
           /**
      -     * Find all annotations (node + edge) that have a specific tag.
      +     * Find all annotations (node + Edge) that have a specific tag.
            */
           public List findByTag(String tag) {
               String normalizedTag = tag.trim().toLowerCase();
      @@ -437,7 +437,7 @@ public int importFromJson(String json) {
                   String line = rawLine.trim();
       
                   if (line.contains("\"nodeAnnotations\"")) { currentSection = "node"; continue; }
      -            if (line.contains("\"edgeAnnotations\"")) { currentSection = "edge"; continue; }
      +            if (line.contains("\"edgeAnnotations\"")) { currentSection = "Edge"; continue; }
       
                   if (line.equals("{") && currentSection != null) { inObject = true; continue; }
       
      @@ -448,7 +448,7 @@ public int importFromJson(String json) {
                           if ("NODE".equals(elementType)) {
                               a = annotateNode(elementId);
                           } else {
      -                        // Parse edge key "v1--v2"
      +                        // Parse Edge key "v1--v2"
                               String[] parts = elementId.split("--", 2);
                               if (parts.length == 2) {
                                   a = annotateEdge(parts[0], parts[1]);
      diff --git a/Gvisual/src/gvisual/GraphAnomalyDetector.java b/Gvisual/src/gvisual/GraphAnomalyDetector.java
      index f0790ef..b2dbd94 100644
      --- a/Gvisual/src/gvisual/GraphAnomalyDetector.java
      +++ b/Gvisual/src/gvisual/GraphAnomalyDetector.java
      @@ -12,7 +12,7 @@
        *   
    • Degree — number of connections (too many or too few)
    • *
    • Local clustering coefficient — how tightly connected a node's * neighbors are (isolated vs. cliquish)
    • - *
    • Edge-type diversity — Shannon entropy across edge categories + *
    • Edge-type diversity — Shannon entropy across Edge categories * (concentrated vs. uniformly spread)
    • *
    • Neighbor degree deviation — how different a node's degree is * from its neighbors' average (popularity mismatch)
    • @@ -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"); } @@ -415,24 +415,24 @@ private double computeClusteringCoeff(String v) { } } } - // Each triangle edge counted twice (once from each endpoint) + // Each triangle Edge counted twice (once from each endpoint) triangleEdges /= 2; return (2.0 * triangleEdges) / (k * (k - 1)); } /** - * Computes Shannon entropy of edge-type distribution for a node. + * Computes Shannon entropy of Edge-type distribution for a node. *

      Higher entropy = more diverse connections across categories.

      *

      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..390f056 100644 --- a/Gvisual/src/gvisual/GraphAsciiRenderer.java +++ b/Gvisual/src/gvisual/GraphAsciiRenderer.java @@ -13,7 +13,7 @@ *

      Features

      *
        *
      • Force-directed node placement on a text grid
      • - *
      • ASCII and Unicode box-drawing edge styles
      • + *
      • ASCII and Unicode box-drawing Edge styles
      • *
      • Node labels with degree annotations
      • *
      • Configurable grid size (width × height in characters)
      • *
      • Edge weight display
      • @@ -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"); } @@ -103,7 +103,7 @@ public void setShowDegree(boolean showDegree) { this.showDegree = showDegree; } - /** Show edge weight along edges. */ + /** Show Edge weight along edges. */ public void setShowWeight(boolean showWeight) { this.showWeight = showWeight; } @@ -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; @@ -171,7 +171,7 @@ public String render() { drawEdge(grid, p1[0], p1[1], p2[0], p2[1]); } - // Draw nodes (overwrite edge chars at node positions) + // Draw nodes (overwrite Edge chars at node positions) for (String vertex : graph.getVertices()) { int[] pos = gridPos.get(vertex); if (pos == 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..226ba4f 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..5cc6ff9 100644 --- a/Gvisual/src/gvisual/GraphClusterQualityAnalyzer.java +++ b/Gvisual/src/gvisual/GraphClusterQualityAnalyzer.java @@ -15,7 +15,7 @@ * indicates significant community structure. Range: [-0.5, 1.0]. *
      • Coverage: Fraction of all edges that fall within clusters. * Higher is better (all edges inside = 1.0).
      • - *
      • Conductance (per-cluster): Ratio of cut edges to total edge + *
      • Conductance (per-cluster): Ratio of cut edges to total Edge * boundary. Lower is better (fewer edges leaving the cluster). * Minimum conductance reported as the worst-case cluster.
      • *
      • Normalized Cut (NCut): Sum of conductances across all clusters. @@ -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)) {
        @@ -320,7 +320,7 @@ public QualityReport evaluate(Map clustering) {
                             }
                         }
                     }
        -            clusterIntra /= 2; // each intra-edge counted from both endpoints
        +            clusterIntra /= 2; // each intra-Edge counted from both endpoints
         
                     // Conductance: cut / min(totalDegree, 2m - totalDegree)
                     double denom = Math.min(totalDegree, 2 * totalEdges - totalDegree);
        @@ -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..26b4d8e 100644
        --- a/Gvisual/src/gvisual/GraphColoringAnalyzer.java
        +++ b/Gvisual/src/gvisual/GraphColoringAnalyzer.java
        @@ -7,7 +7,7 @@
          * Comprehensive graph coloring analyzer -- greedy coloring with multiple
          * vertex orderings (natural, largest-first, smallest-last, DSatur),
          * chromatic number bounds, k-colorability checking, coloring verification,
        - * color class analysis, edge chromatic number estimation (Vizing's theorem),
        + * color class analysis, Edge chromatic number estimation (Vizing's theorem),
          * and report generation.
          *
          * 

        Graph coloring assigns labels (colors) to vertices so that no two @@ -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); @@ -474,11 +474,11 @@ public Map analyzeColorClasses(ColoringResult result) { // ── Edge Chromatic Number (Vizing's Theorem) ──────────────────── /** - * Estimates the edge chromatic number bounds using Vizing's theorem. - * For any simple graph, the edge chromatic number χ'(G) satisfies: + * Estimates the Edge chromatic number bounds using Vizing's theorem. + * For any simple graph, the Edge chromatic number χ'(G) satisfies: * Δ(G) ≤ χ'(G) ≤ Δ(G) + 1, where Δ(G) is the maximum degree. * - * @return array with [lower bound, upper bound] for edge chromatic number + * @return array with [lower bound, upper bound] for Edge chromatic number */ public int[] edgeChromaticBounds() { Collection vertices = graph.getVertices(); @@ -499,7 +499,7 @@ public int[] edgeChromaticBounds() { /** * Returns the maximum vertex degree (Δ), which is the Vizing lower - * bound for the edge chromatic number. + * bound for the Edge chromatic number. * * @return maximum degree */ @@ -518,7 +518,7 @@ public int maxDegree() { /** * Generates a comprehensive coloring report including greedy and - * DSatur results, chromatic bounds, edge chromatic bounds, and + * DSatur results, chromatic bounds, Edge chromatic bounds, and * color class analysis. * * @return formatted report string @@ -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/GraphComplementAnalyzer.java b/Gvisual/src/gvisual/GraphComplementAnalyzer.java index c5ee91a..2248df2 100644 --- a/Gvisual/src/gvisual/GraphComplementAnalyzer.java +++ b/Gvisual/src/gvisual/GraphComplementAnalyzer.java @@ -8,7 +8,7 @@ * Computes the complement graph of a given graph and provides comparative * analysis between the original and its complement. * - *

        The complement G' of a graph G has the same vertices, but an edge exists in G' + *

        The complement G' of a graph G has the same vertices, but an Edge exists in G' * if and only if it does not exist in G. This is useful for understanding * graph density, identifying missing connections, and studying structural properties * that become apparent when relationships are inverted.

        @@ -16,7 +16,7 @@ *

        Features

        *
          *
        • Build the complement graph as a new JUNG UndirectedSparseGraph
        • - *
        • Compare edge counts, density, and degree distributions
        • + *
        • Compare Edge counts, density, and degree distributions
        • *
        • Identify vertices whose degree changes most dramatically
        • *
        • Check self-complementarity (isomorphism with complement)
        • *
        • Export a textual comparison report
        • @@ -34,8 +34,8 @@ private GraphComplementAnalyzer() { /* utility class */ } * @param graph the original graph * @return a new graph containing all edges not present in the original */ - public static Graph buildComplement(Graph graph) { - UndirectedSparseGraph complement = new UndirectedSparseGraph<>(); + public static Graph buildComplement(Graph graph) { + UndirectedSparseGraph complement = new UndirectedSparseGraph<>(); List vertices = new ArrayList<>(graph.getVertices()); for (String v : vertices) { @@ -43,7 +43,7 @@ public static Graph buildComplement(Graph graph) { } Set existingEdges = new HashSet<>(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { String v1 = e.getVertex1(); String v2 = e.getVertex2(); existingEdges.add(edgeKey(v1, v2)); @@ -55,7 +55,7 @@ public static Graph buildComplement(Graph graph) { String v1 = vertices.get(i); String v2 = vertices.get(j); if (!existingEdges.contains(edgeKey(v1, v2))) { - edge e = new edge(v1, v2, "complement_" + edgeId++); + Edge e = new Edge(v1, v2, "complement_" + edgeId++); complement.addEdge(e, v1, v2); } } @@ -71,8 +71,8 @@ public static Graph buildComplement(Graph graph) { * @param graph the original graph * @return a formatted analysis report string */ - public static String analyze(Graph graph) { - Graph complement = buildComplement(graph); + public static String analyze(Graph graph) { + Graph complement = buildComplement(graph); int n = graph.getVertexCount(); int origEdges = graph.getEdgeCount(); int compEdges = complement.getEdgeCount(); @@ -98,18 +98,18 @@ public static String analyze(Graph graph) { sb.append(String.format(" Avg degree: %.2f%n", avgDegree(complement))); sb.append("\n"); - // Verify edge counts sum correctly + // Verify Edge counts sum correctly sb.append("── Validation ─────────────────────────────\n"); sb.append(" Orig + Complement: ").append(origEdges + compEdges).append("\n"); sb.append(" Expected (n*(n-1)/2):").append(maxEdges).append("\n"); sb.append(" Valid: ").append(origEdges + compEdges == maxEdges ? "✓" : "✗").append("\n\n"); - // Self-complementary check (quick heuristic: edge count must equal n*(n-1)/4) + // Self-complementary check (quick heuristic: Edge count must equal n*(n-1)/4) boolean couldBeSelfComplementary = (maxEdges % 2 == 0) && (origEdges == maxEdges / 2); sb.append("── Self-Complementary ─────────────────────\n"); sb.append(" Edge-count test: ").append(couldBeSelfComplementary ? "PASS (possible)" : "FAIL").append("\n"); if (couldBeSelfComplementary) { - sb.append(" (Full isomorphism check not performed — edge count is necessary but not sufficient)\n"); + sb.append(" (Full isomorphism check not performed — Edge count is necessary but not sufficient)\n"); } sb.append("\n"); @@ -139,15 +139,15 @@ public static String analyze(Graph graph) { } /** - * Returns the complement graph's edge list as a list of string pairs. + * Returns the complement graph's Edge list as a list of string pairs. * * @param graph the original graph * @return list of [vertex1, vertex2] arrays representing complement edges */ - public static List getComplementEdgeList(Graph graph) { - Graph complement = buildComplement(graph); + public static List getComplementEdgeList(Graph graph) { + Graph complement = buildComplement(graph); List result = new ArrayList<>(); - for (edge e : complement.getEdges()) { + for (Edge e : complement.getEdges()) { result.add(new String[]{e.getVertex1(), e.getVertex2()}); } return result; @@ -164,7 +164,7 @@ private static double density(int edges, int vertices) { return (2.0 * edges) / (vertices * (vertices - 1)); } - private static double avgDegree(Graph g) { + private static double avgDegree(Graph g) { if (g.getVertexCount() == 0) return 0.0; double sum = 0; for (String v : g.getVertices()) { @@ -174,7 +174,7 @@ private static double avgDegree(Graph g) { } private static List computeDegreeChanges( - Graph orig, Graph comp) { + Graph orig, Graph comp) { List list = new ArrayList<>(); for (String v : orig.getVertices()) { int od = orig.degree(v); diff --git a/Gvisual/src/gvisual/GraphCompressor.java b/Gvisual/src/gvisual/GraphCompressor.java index 352a646..a2d380e 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,10 +328,10 @@ 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; + info.Edge = superEdge; } info.count++; info.totalWeight += e.getWeight(); @@ -339,7 +339,7 @@ private CompressionResult buildQuotientGraph(List> groups, String s // Set aggregated weights for (SuperEdgeInfo info : superEdgeInfos.values()) { - info.edge.setWeight(info.totalWeight); + info.Edge.setWeight(info.totalWeight); } return new CompressionResult( @@ -359,7 +359,7 @@ private static double jaccardSimilarity(Set a, Set b) { } private String formatReportLine(String label, CompressionResult result) { - return String.format(" %-30s → %d supernodes, %d edges (%.1f%% node reduction, %.1f%% edge reduction)\n", + return String.format(" %-30s → %d supernodes, %d edges (%.1f%% node reduction, %.1f%% Edge reduction)\n", label, result.getCompressedNodeCount(), result.getCompressedEdgeCount(), @@ -368,7 +368,7 @@ private String formatReportLine(String label, CompressionResult result) { } private static class SuperEdgeInfo { - edge edge; + Edge Edge; int count; float totalWeight; } @@ -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; } @@ -413,13 +413,13 @@ public static class CompressionResult { /** Original node count. */ public int getOriginalNodeCount() { return original.getVertexCount(); } - /** Original edge count. */ + /** Original Edge count. */ public int getOriginalEdgeCount() { return original.getEdgeCount(); } /** Compressed node count. */ public int getCompressedNodeCount() { return compressed.getVertexCount(); } - /** Compressed edge count. */ + /** Compressed Edge count. */ public int getCompressedEdgeCount() { return compressed.getEdgeCount(); } /** Compression ratio (compressed/original nodes). */ 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..fc4538a 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"); } @@ -51,7 +51,7 @@ public GraphDiffAnalyzer(Graph graphA, Graph graphB) /** * Holds the complete diff result between two graphs. *

          - * Includes node/edge differences, similarity metrics, edit distance, + * Includes node/Edge differences, similarity metrics, edit distance, * and degree changes — all computed in a single pass by * {@link GraphDiffAnalyzer#computeDiff()}. */ @@ -105,7 +105,7 @@ public DiffResult(Set addedNodes, Set removedNodes, /** Jaccard similarity of node sets: |A∩B| / |A∪B|. */ public double getNodeJaccard() { return nodeJaccard; } - /** Jaccard similarity of edge sets: |A∩B| / |A∪B|. */ + /** Jaccard similarity of Edge sets: |A∩B| / |A∪B|. */ public double getEdgeJaccard() { return edgeJaccard; } /** @@ -149,7 +149,7 @@ public String getSummary() { } /** - * Represents an edge for diff purposes (endpoint pair, normalized order + * Represents an Edge for diff purposes (endpoint pair, normalized order * for undirected comparison). */ public static class EdgeDiff { @@ -196,7 +196,7 @@ public String toString() { /** * Compute the full diff between graphA and graphB. *

          - * This single call computes all node/edge differences, Jaccard + * This single call computes all node/Edge differences, Jaccard * similarity, edit distance, and degree changes. Use the returned * {@link DiffResult} to access everything — there is no need to call * {@link #findDegreeChanges()} or {@link #computeEditDistance()} @@ -270,7 +270,7 @@ public Map findDegreeChanges() { } /** - * Compute the edit distance: total node/edge additions + removals + * Compute the edit distance: total node/Edge additions + removals * needed to transform A into B. *

          * Convenience method — delegates to {@link #computeDiff()} internally. @@ -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..cd270a9 100644 --- a/Gvisual/src/gvisual/GraphDistanceDistribution.java +++ b/Gvisual/src/gvisual/GraphDistanceDistribution.java @@ -21,14 +21,14 @@ *

        • Text report — human-readable distance distribution summary
        • *
        * - *

        All computations use unweighted BFS. For directed graphs the out-edge + *

        All computations use unweighted BFS. For directed graphs the out-Edge * direction is followed. Distance to self is 0, unreachable pairs use -1.

        * * @author zalenix */ 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..aa653ad 100644 --- a/Gvisual/src/gvisual/GraphEntropyAnalyzer.java +++ b/Gvisual/src/gvisual/GraphEntropyAnalyzer.java @@ -18,14 +18,14 @@ * set of neighbour degree values. Captures local structural * diversity around each node.
      • *
      • Edge type entropy — Shannon entropy over the distribution of - * edge categories (friend, classmate, etc.). Measures diversity + * Edge categories (friend, classmate, etc.). Measures diversity * of relationship types in the network.
      • *
      • Topological information content — based on degree-sequence * equivalence classes (orbits under automorphism approximation). * Measures how much information is needed to distinguish nodes.
      • *
      • Random walk entropy rate — the asymptotic entropy per step * of a random walker on the graph, H = log2(2m) - (1/2m) Σ d(v) log2 d(v), - * where d(v) is the degree of vertex v and m is the edge count.
      • + * where d(v) is the degree of vertex v and m is the Edge count. *
      • Chromatic entropy — entropy based on vertex coloring using * greedy coloring (largest-first), measuring color distribution * uniformity.
      • @@ -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<>(); @@ -244,14 +244,14 @@ private void computeNeighbourhoodEntropy() { } /** - * Shannon entropy over edge type distribution. + * Shannon entropy over Edge type distribution. */ private void computeEdgeTypeEntropy() { int m = graph.getEdgeCount(); 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); @@ -615,7 +615,7 @@ public String generateReport() { sb.append(" * High Von Neumann entropy suggests complex, well-connected structure.\n"); } if (edgeTypeEntropy > 1.0) { - sb.append(" * High edge type entropy indicates diverse relationship types.\n"); + sb.append(" * High Edge type entropy indicates diverse relationship types.\n"); } if (degreeCCMutualInfo > 0.5) { sb.append(" * Significant degree-CC mutual information: degree strongly predicts clustering.\n"); diff --git a/Gvisual/src/gvisual/GraphFileParser.java b/Gvisual/src/gvisual/GraphFileParser.java index 3138641..3c43608 100644 --- a/Gvisual/src/gvisual/GraphFileParser.java +++ b/Gvisual/src/gvisual/GraphFileParser.java @@ -13,7 +13,7 @@ /** * Parses a graph definition file (nodes + edges) into a JUNG graph and - * classified edge lists. + * classified Edge lists. * *

        Extracted from {@link Main#addGraph()} to separate file I/O and * parsing logic from Swing UI construction. This makes the parsing @@ -31,24 +31,24 @@ * CL B C 2.0 *

      * - * Each edge line: {@code } + * Each Edge line: {@code } */ public class GraphFileParser { private static final Logger LOGGER = Logger.getLogger(GraphFileParser.class.getName()); /** - * Result of parsing a graph file. Holds the graph, classified edge + * Result of parsing a graph file. Holds the graph, classified Edge * 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) { + /** Convenience accessor for a single Edge type's list (never null). */ + public List getEdges(EdgeType type) { return edgesByType.getOrDefault(type, Collections.emptyList()); } @@ -79,17 +79,17 @@ public List getEdges(EdgeType type) { * Parse a graph file into a {@link ParseResult}. * * @param filePath path to the graph definition file - * @param visibleFilter predicate that returns {@code true} for edge type + * @param visibleFilter predicate that returns {@code true} for Edge type * codes that should be added to the graph (not just * classified). Pass {@code code -> true} to include all. - * @return parsed result containing graph, edge lists, and vertices + * @return parsed result containing graph, Edge lists, and vertices * @throws IOException if the file cannot be read */ 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<>()); } @@ -131,7 +131,7 @@ public static ParseResult parse(String filePath, Predicate visibleFilter // Edge line: String[] parts = line.split("\\s+"); if (parts.length < 4) { - LOGGER.warning("Skipping malformed edge line: " + line); + LOGGER.warning("Skipping malformed Edge line: " + line); skipped++; continue; } @@ -140,24 +140,24 @@ public static ParseResult parse(String filePath, Predicate visibleFilter try { weight = Float.parseFloat(parts[3]); } catch (NumberFormatException e) { - LOGGER.warning("Skipping edge with invalid weight: " + line); + LOGGER.warning("Skipping Edge with invalid weight: " + line); skipped++; continue; } if (Float.isNaN(weight) || Float.isInfinite(weight)) { - LOGGER.warning("Skipping edge with non-finite weight: " + line); + LOGGER.warning("Skipping Edge with non-finite weight: " + line); skipped++; 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); - // Set label on first edge of each type for the legend + 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()); } @@ -178,7 +178,7 @@ public static ParseResult parse(String filePath, Predicate visibleFilter } /** - * Convenience overload that includes all edge types. + * Convenience overload that includes all Edge types. */ public static ParseResult parse(String filePath) throws IOException { return parse(filePath, code -> true); diff --git a/Gvisual/src/gvisual/GraphGenerator.java b/Gvisual/src/gvisual/GraphGenerator.java index 8832448..274045b 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; } @@ -144,20 +144,20 @@ private String nodeName(int i) { return "n" + i; } - private edge createEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + private Edge createEdge(String v1, String 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)); @@ -350,19 +350,19 @@ public GeneratedGraph tree(int branchingFactor, int depth) { /** * Creates a random graph using the Erdős–Rényi G(n,p) model. * - *

      Each possible edge is included independently with probability + *

      Each possible Edge is included independently with probability * {@code p}. When p=0, no edges are created; when p=1, a complete * graph results.

      * * @param n number of nodes (must be >= 1) - * @param p edge probability between 0.0 and 1.0 + * @param p Edge probability between 0.0 and 1.0 * @return the generated random graph * @throws IllegalArgumentException if n < 1 or p is out of range */ 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++) { @@ -454,7 +454,7 @@ public GeneratedGraph scaleFreeBa(int n, int m) { * *

      Starts with a ring lattice where each node is connected to * its {@code k} nearest neighbors (k/2 on each side), then - * rewires each edge with probability {@code beta}. Low beta + * rewires each Edge with probability {@code beta}. Low beta * produces regular lattices; high beta produces random graphs; * intermediate values create the "small-world" property * (high clustering + short path lengths).

      @@ -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 @@ -487,7 +487,7 @@ public GeneratedGraph smallWorldWs(int n, int k, double beta) { for (int j = 1; j <= k / 2; j++) { if (random.nextDouble() < beta) { int oldNeighbor = (i + j) % n; - edge existing = g.findEdge(nodeName(i), nodeName(oldNeighbor)); + Edge existing = g.findEdge(nodeName(i), nodeName(oldNeighbor)); if (existing == null) continue; // Find a new target (not self, not already connected) @@ -520,12 +520,12 @@ public GeneratedGraph smallWorldWs(int n, int k, double beta) { * Creates a random bipartite graph with two groups of nodes. * *

      Edges only connect nodes in group A to nodes in group B - * (never within the same group). Each possible cross-group edge + * (never within the same group). Each possible cross-group Edge * is included with probability {@code p}.

      * * @param groupASize size of group A (must be >= 1) * @param groupBSize size of group B (must be >= 1) - * @param p edge probability between 0.0 and 1.0 + * @param p Edge probability between 0.0 and 1.0 * @return the generated bipartite graph * @throws IllegalArgumentException if group sizes < 1 or p is invalid */ @@ -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/GraphHealthChecker.java b/Gvisual/src/gvisual/GraphHealthChecker.java index 4a95bab..137a27d 100644 --- a/Gvisual/src/gvisual/GraphHealthChecker.java +++ b/Gvisual/src/gvisual/GraphHealthChecker.java @@ -23,9 +23,9 @@ */ public class GraphHealthChecker { - private final Graph graph; + private final Graph graph; - public GraphHealthChecker(Graph graph) { + public GraphHealthChecker(Graph graph) { this.graph = Objects.requireNonNull(graph, "graph must not be null"); } @@ -53,9 +53,9 @@ private List findIsolatedNodes() { .collect(Collectors.toList()); } - private List findSelfLoops() { - List loops = new ArrayList<>(); - for (edge e : graph.getEdges()) { + private List findSelfLoops() { + List loops = new ArrayList<>(); + for (Edge e : graph.getEdges()) { Collection endpoints = graph.getEndpoints(e); if (endpoints != null && endpoints.size() == 1) { loops.add(e); @@ -72,7 +72,7 @@ private List findSelfLoops() { private List findParallelEdges() { Set seen = new HashSet<>(); List duplicates = new ArrayList<>(); - for (edge e : graph.getEdges()) { + for (Edge e : graph.getEdges()) { Collection ep = graph.getEndpoints(e); if (ep == null || ep.size() < 2) continue; Iterator it = ep.iterator(); @@ -136,9 +136,9 @@ private List findDegreeOutliers() { } /** Bridge edges whose removal would increase component count. */ - private List findBridges() { + private List findBridges() { // Tarjan's bridge-finding via DFS - List bridges = new ArrayList<>(); + List bridges = new ArrayList<>(); if (graph.getVertexCount() == 0) return bridges; Map disc = new HashMap<>(); @@ -156,7 +156,7 @@ private List findBridges() { private void bridgeDfs(String u, String parent, Map disc, Map low, - Set visited, int[] timer, List bridges) { + Set visited, int[] timer, List bridges) { visited.add(u); disc.put(u, timer[0]); low.put(u, timer[0]); @@ -167,7 +167,7 @@ private void bridgeDfs(String u, String parent, bridgeDfs(v, u, disc, low, visited, timer, bridges); low.put(u, Math.min(low.get(u), low.get(v))); if (low.get(v) > disc.get(u)) { - edge bridgeEdge = graph.findEdge(u, v); + Edge bridgeEdge = graph.findEdge(u, v); if (bridgeEdge != null) bridges.add(bridgeEdge); } } else if (!v.equals(parent)) { @@ -247,7 +247,7 @@ public static String toHtml(HealthReport r) { if (r.parallelEdgePairs.isEmpty()) { sb.append("
      ✅ No parallel edges
      "); } else { - sb.append(String.format("
      ⚠️ %d parallel edge pair(s)
      ", r.parallelEdgePairs.size())); + sb.append(String.format("
      ⚠️ %d parallel Edge pair(s)
      ", r.parallelEdgePairs.size())); } if (r.componentSizes.size() <= 1) { sb.append("
      ✅ Graph is connected
      "); @@ -257,9 +257,9 @@ public static String toHtml(HealthReport r) { .map(Object::toString).collect(Collectors.toList()), 15))); } if (r.bridges.isEmpty()) { - sb.append("
      ✅ No bridge edges (graph is 2-edge-connected)
      "); + sb.append("
      ✅ No bridge edges (graph is 2-Edge-connected)
      "); } else { - sb.append(String.format("
      ⚠️ %d bridge edge(s) — removing any would disconnect the graph
      ", r.bridges.size())); + sb.append(String.format("
      ⚠️ %d bridge Edge(s) — removing any would disconnect the graph
      ", r.bridges.size())); } if (r.degreeOutliers.isEmpty()) { sb.append("
      ✅ No degree outliers
      "); @@ -284,11 +284,11 @@ public static class HealthReport { public int edgeCount; public int score; public List isolatedNodes = Collections.emptyList(); - public List selfLoops = Collections.emptyList(); + public List selfLoops = Collections.emptyList(); public List parallelEdgePairs = Collections.emptyList(); public List componentSizes = Collections.emptyList(); public List degreeOutliers = Collections.emptyList(); - public List bridges = Collections.emptyList(); + public List bridges = Collections.emptyList(); /** Plain text summary. */ public String toText() { @@ -299,7 +299,7 @@ public String toText() { nodeCount, edgeCount, componentSizes.size())); sb.append(String.format("Isolated nodes: %d\n", isolatedNodes.size())); sb.append(String.format("Self-loops: %d\n", selfLoops.size())); - sb.append(String.format("Parallel edge pairs: %d\n", parallelEdgePairs.size())); + sb.append(String.format("Parallel Edge pairs: %d\n", parallelEdgePairs.size())); sb.append(String.format("Bridge edges: %d\n", bridges.size())); sb.append(String.format("Degree outliers: %d\n", degreeOutliers.size())); if (!isolatedNodes.isEmpty()) { diff --git a/Gvisual/src/gvisual/GraphIsomorphismAnalyzer.java b/Gvisual/src/gvisual/GraphIsomorphismAnalyzer.java index 9e40fbb..7d3e330 100644 --- a/Gvisual/src/gvisual/GraphIsomorphismAnalyzer.java +++ b/Gvisual/src/gvisual/GraphIsomorphismAnalyzer.java @@ -9,12 +9,12 @@ * same structure (are isomorphic), ignoring vertex labels. * *

      Two graphs G1 and G2 are isomorphic if there exists a - * bijection f: V(G1) → V(G2) such that (u, v) is an edge in G1 - * if and only if (f(u), f(v)) is an edge in G2.

      + * bijection f: V(G1) → V(G2) such that (u, v) is an Edge in G1 + * if and only if (f(u), f(v)) is an Edge in G2.

      * *

      Uses a multi-stage approach:

      *
        - *
      1. Fast rejection: vertex count, edge count, degree sequence
      2. + *
      3. Fast rejection: vertex count, Edge count, degree sequence
      4. *
      5. Degree-based partitioning: vertices grouped by degree
      6. *
      7. Backtracking search: VF2-style matching with feasibility pruning
      8. *
      @@ -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"); } @@ -125,12 +125,12 @@ public IsomorphismResult analyze() { degSeq1, degSeq2); } - // Fast rejection: edge count + // Fast rejection: Edge count int edgeCount1 = graph1.getEdgeCount(); int edgeCount2 = graph2.getEdgeCount(); if (edgeCount1 != edgeCount2) { return new IsomorphismResult(false, null, - "Different edge counts (" + edgeCount1 + + "Different Edge counts (" + edgeCount1 + " vs " + edgeCount2 + ")", degSeq1, degSeq2); } @@ -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..c79e54a 100644 --- a/Gvisual/src/gvisual/GraphMLExporter.java +++ b/Gvisual/src/gvisual/GraphMLExporter.java @@ -15,7 +15,7 @@ *
        *
      • All vertices with their node IDs
      • *
      • All edges with type, weight, label, and endpoint metadata
      • - *
      • Graph metadata (timestamp, node count, edge count)
      • + *
      • Graph metadata (timestamp, node count, Edge count)
      • *
      • GraphML key definitions for custom attributes
      • *
      * @@ -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,16 +121,16 @@ 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())); } /** - * Internal: exports the graph to a GraphML XML string using the given edge list. + * Internal: exports the graph to a GraphML XML string using the given Edge list. * * @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 @@ -140,15 +140,15 @@ private String exportToString(List edgesToExport) { sb.append(" xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns\n"); sb.append(" http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\">\n"); - // Key definitions for node and edge attributes + // Key definitions for node and Edge attributes sb.append(" \n"); sb.append(" \n"); sb.append(" \n"); - sb.append(" \n"); - sb.append(" \n"); - sb.append(" \n"); - sb.append(" \n"); + sb.append(" \n"); + sb.append(" \n"); + sb.append(" \n"); + sb.append(" \n"); // Graph element sb.append(" \n"); @@ -179,9 +179,9 @@ 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(" \n"); @@ -199,7 +199,7 @@ private String exportToString(List edgesToExport) { sb.append(" ").append(escapeXml(e.getLabel())).append("\n"); } - sb.append(" \n"); + sb.append(" \n"); } sb.append(" \n"); @@ -209,9 +209,9 @@ private String exportToString(List edgesToExport) { } /** - * Returns a human-readable label for an edge type code. + * Returns a human-readable label for an Edge type code. * - * @param typeCode the edge type code (f, fs, c, s, sg) + * @param typeCode the Edge type code (f, fs, c, s, sg) * @return human-readable label */ static String getTypeLabel(String typeCode) { @@ -275,7 +275,7 @@ public int getVertexCount() { * Returns the number of edges that will be exported. * If allEdges is non-empty, returns allEdges count; otherwise graph edges. * - * @return edge count + * @return Edge count */ public int getEdgeCount() { if (!allEdges.isEmpty()) { diff --git a/Gvisual/src/gvisual/GraphMerger.java b/Gvisual/src/gvisual/GraphMerger.java index 68ce656..2a65ef4 100644 --- a/Gvisual/src/gvisual/GraphMerger.java +++ b/Gvisual/src/gvisual/GraphMerger.java @@ -7,7 +7,7 @@ /** * Merges two graphs using configurable strategies for combining vertices - * and edges, with conflict resolution for overlapping edge attributes. + * and edges, with conflict resolution for overlapping Edge attributes. * *

      Merge Strategies

      *
        @@ -19,7 +19,7 @@ *
      * *

      Edge Conflict Resolution

      - * When the same edge pair exists in both graphs with different weights: + * When the same Edge pair exists in both graphs with different weights: *
        *
      • KEEP_LEFT — use weight from graph A
      • *
      • KEEP_RIGHT — use weight from graph B
      • @@ -33,7 +33,7 @@ *
          * MergeResult result = GraphMerger.merge(graphA, graphB, Strategy.UNION,
          *     EdgeConflict.AVERAGE);
        - * Graph<String, edge> merged = result.getMergedGraph();
        + * Graph<String, Edge> merged = result.getMergedGraph();
          * 
        * * @author zalenix @@ -56,7 +56,7 @@ public enum Strategy { RIGHT_JOIN } - /** Edge conflict resolution when the same edge pair exists in both graphs. */ + /** Edge conflict resolution when the same Edge pair exists in both graphs. */ public enum EdgeConflict { /** Keep weight from graph A. */ KEEP_LEFT, @@ -76,7 +76,7 @@ public enum EdgeConflict { * Result of a merge operation, including the merged graph and statistics. */ public static final class MergeResult { - private final Graph 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,21 +155,21 @@ 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); } /** - * Merge two graphs with the given strategy and edge conflict resolution. + * Merge two graphs with the given strategy and Edge conflict resolution. * * @param a first graph * @param b second graph * @param strategy merge strategy - * @param edgeConflict how to resolve conflicting edge weights + * @param edgeConflict how to resolve conflicting Edge weights * @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,11 +235,11 @@ 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 - edge existing = edgeIndex.get(key); + Edge existing = edgeIndex.get(key); existing.setWeight(resolveWeight(existing.getWeight(), e.getWeight(), conflict)); conflicts[0]++; } else { @@ -248,27 +248,27 @@ 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()) { + // Build Edge index for B + 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); - edge bEdge = bEdges.get(key); + Edge bEdge = bEdges.get(key); if (bEdge != null) { - edge merged = cloneEdge(e); + Edge merged = cloneEdge(e); merged.setWeight(resolveWeight(e.getWeight(), bEdge.getWeight(), conflict)); result.addEdge(merged, e.getVertex1(), e.getVertex2()); if (e.getWeight() != bEdge.getWeight()) conflicts[0]++; @@ -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 + // 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; } String key = edgeKey(e); if (edgeIndex.containsKey(key)) { - edge existing = edgeIndex.get(key); + Edge existing = edgeIndex.get(key); existing.setWeight(resolveWeight(existing.getWeight(), e.getWeight(), conflict)); conflicts[0]++; } else { @@ -347,22 +347,22 @@ private static void mergeLeftJoin(Graph primary, Graph g, String v1, String v2) { - edge e = g.findEdge(v1, v2); + /** Find an Edge between two vertices in a graph. */ + 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()); + /** Clone an Edge (deep copy). */ + 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,14 +371,14 @@ 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); } } - /** Resolve edge weight conflict according to the chosen strategy. */ + /** Resolve Edge weight conflict according to the chosen strategy. */ static float resolveWeight(float left, float right, EdgeConflict conflict) { switch (conflict) { case KEEP_LEFT: return left; diff --git a/Gvisual/src/gvisual/GraphMinorAnalyzer.java b/Gvisual/src/gvisual/GraphMinorAnalyzer.java index e1ffccc..192f90a 100644 --- a/Gvisual/src/gvisual/GraphMinorAnalyzer.java +++ b/Gvisual/src/gvisual/GraphMinorAnalyzer.java @@ -9,9 +9,9 @@ * *

        Capabilities

        *
          - *
        • Edge contraction — contract an edge, merging its endpoints
        • + *
        • Edge contraction — contract an Edge, merging its endpoints
        • *
        • Vertex deletion — remove a vertex and its incident edges
        • - *
        • Edge deletion — remove an edge
        • + *
        • Edge deletion — remove an Edge
        • *
        • Minor sequence — apply a sequence of operations to derive a minor
        • *
        • K₅ minor test — check if graph contains K₅ as a minor
        • *
        • K₃,₃ minor test — check if graph contains K₃,₃ as a minor
        • @@ -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; } @@ -78,12 +78,12 @@ public Graph deleteVertices(Collection vertices) { // ── Edge deletion ─────────────────────────────────────────────────── /** - * Returns a new graph with the edge between v1 and v2 removed. + * Returns a new graph with the Edge between v1 and v2 removed. */ - 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); + 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); return result; } @@ -91,13 +91,13 @@ public Graph deleteEdge(String v1, String v2) { // ── Edge contraction ──────────────────────────────────────────────── /** - * Contracts the edge between v1 and v2, merging v2 into v1. + * 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); + throw new IllegalArgumentException("No Edge between " + v1 + " and " + v2); + 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); @@ -113,9 +113,9 @@ public static Graph contractEdge(Graph g, String v1, } /** - * Contracts the edge between v1 and v2 on the instance graph. + * 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,15 +152,15 @@ 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: g.removeVertex(op.v1); break; case DELETE_EDGE: - edge de = g.findEdge(op.v1, op.v2); + Edge de = g.findEdge(op.v1, op.v2); if (de != null) g.removeEdge(de); break; case CONTRACT_EDGE: @@ -177,7 +177,7 @@ public Graph applySequence(List ops) { /** * Estimates the Hadwiger number — the largest k such that K_k is a minor. - * Uses a greedy approach: repeatedly contract the edge whose endpoints + * Uses a greedy approach: repeatedly contract the Edge whose endpoints * have the most common non-neighbors, tracking the effective clique. */ public int hadwigerNumber() { @@ -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 @@ -200,10 +200,10 @@ public int hadwigerNumber() { } best = Math.max(best, findLargestClique(g)); - // Find best edge to contract: endpoints sharing most neighbors + // 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; + 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(); @@ -409,17 +409,17 @@ public int contractionDegeneracy() { // ── Subdivision / Topological minor ───────────────────────────────── /** - * Subdivides an edge: replaces edge (v1,v2) with v1-new-v2. + * 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); - edge e = result.findEdge(v1, v2); - if (e == null) throw new IllegalArgumentException("No edge between " + v1 + " and " + v2); + 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..a31a40a 100644 --- a/Gvisual/src/gvisual/GraphNeighborhoodAnalyzer.java +++ b/Gvisual/src/gvisual/GraphNeighborhoodAnalyzer.java @@ -16,7 +16,7 @@ * hop depth, revealing local topology (tree-like vs mesh-like) *
        • Neighborhood overlap — Jaccard similarity of k-hop * neighborhoods between two vertices, measuring structural proximity
        • - *
        • Local density — edge density within the k-hop induced + *
        • Local density — Edge density within the k-hop induced * subgraph, indicating how tightly connected a neighbourhood is
        • *
        • Boundary vertices — vertices exactly k hops away (the * frontier), useful for expansion analysis
        • @@ -28,14 +28,14 @@ *
        * *

        All computations use BFS from the source vertex. For directed graphs - * the successor (out-edge) direction is followed. The source vertex itself + * the successor (out-Edge) direction is followed. The source vertex itself * is always at depth 0.

        * * @author zalenix */ 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"); } @@ -185,7 +185,7 @@ public List getExpansionRates(String source, int maxK) { // ------------------------------------------------------------------ /** - * Computes the edge density of the induced subgraph on the k-hop + * Computes the Edge density of the induced subgraph on the k-hop * neighborhood of the source vertex. * *

        Density = 2 * |edges in subgraph| / (n * (n-1)) for n > 1, @@ -194,7 +194,7 @@ public List getExpansionRates(String source, int maxK) { * * @param source starting vertex * @param k hop distance - * @return edge density in [0.0, 1.0] + * @return Edge density in [0.0, 1.0] */ public double getLocalDensity(String source, int k) { Set neighborhood = getKHopNeighborhood(source, k); @@ -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..133e8d5 100644 --- a/Gvisual/src/gvisual/GraphPartitioner.java +++ b/Gvisual/src/gvisual/GraphPartitioner.java @@ -4,19 +4,19 @@ import java.util.*; /** - * Partitions a JUNG graph into k balanced parts while minimizing edge cuts. + * Partitions a JUNG graph into k balanced parts while minimizing Edge cuts. * Implements multiple partitioning strategies: * *

          *
        • BFS-based — grows partitions from seed vertices using breadth-first * traversal, balancing partition sizes at each step.
        • *
        • Kernighan-Lin refinement — iteratively swaps vertex pairs between - * partitions to reduce edge cuts (2-way, applied recursively for k-way).
        • + * partitions to reduce Edge cuts (2-way, applied recursively for k-way). *
        • Spectral bisection — uses the Fiedler vector (second-smallest eigenvector * of the Laplacian) to find a natural split, refined with KL swaps.
        • *
        * - *

        Produces a {@link PartitionResult} with per-partition membership, edge cut count, + *

        Produces a {@link PartitionResult} with per-partition membership, Edge cut count, * imbalance ratio, cut ratio, and partition-level metrics (size, internal/external edges, * conductance).

        * @@ -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"); } @@ -250,7 +250,7 @@ private Map partitionKL(int k) { /** * Kernighan-Lin refinement: for each pair of partitions, try swapping - * vertices to reduce edge cuts. Repeat until no improvement. + * vertices to reduce Edge cuts. Repeat until no improvement. */ private Map refineKL(Map assignment, int k) { boolean improved = true; @@ -327,7 +327,7 @@ private boolean refineKLPair(Map assignment, int partA, int par /** * Compute the gain from swapping u (in partA) with v (in partB). - * Gain = reduction in edge cuts after the swap. + * Gain = reduction in Edge cuts after the swap. */ private int computeSwapGain(Map assignment, String u, String v, int partA, int partB) { @@ -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; @@ -619,12 +619,12 @@ public static class PartitionResult { partMap.computeIfAbsent(e.getValue(), x -> new HashSet<>()).add(e.getKey()); } - // Count edge cuts and per-partition metrics + // Count Edge cuts and per-partition metrics int cuts = 0; 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..2122d74 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; @@ -97,7 +97,7 @@ public Path(List vertices, double totalWeight) { /** Number of edges in the path. */ public int getHopCount() { return Math.max(0, vertices.size() - 1); } - /** Total edge weight along the path. */ + /** Total Edge weight along the path. */ public double getTotalWeight() { return totalWeight; } /** First vertex. */ @@ -354,7 +354,7 @@ public Path findPathAvoiding(String source, String target, } /** - * Convenience: build an edge-pair key for avoidance sets. + * Convenience: build an Edge-pair key for avoidance sets. * * @param v1 first vertex * @param v2 second vertex @@ -634,7 +634,7 @@ public String generateReport(String source, String target) { // ── Internal helpers ────────────────────────────────────────── /** - * Dijkstra shortest path with optional node/edge exclusions. + * Dijkstra shortest path with optional node/Edge exclusions. */ private Path dijkstra(String source, String target, Set excludeNodes, diff --git a/Gvisual/src/gvisual/GraphPathExplorerTest.java b/Gvisual/src/gvisual/GraphPathExplorerTest.java index bbdbbd4..5b172ff 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); } @@ -344,8 +344,8 @@ private static void testAvoidanceRouting() { Set avoidEdges = new HashSet<>(); 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: avoid A-B Edge exists", p != null); + 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..3292147 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,17 +131,17 @@ 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;
             }
         
             private int edgeCounter = 0;
         
             /**
        -     * Creates a fresh product edge.
        +     * Creates a fresh product Edge.
              */
        -    private edge newProductEdge(String u1, String v1, String u2, String v2) {
        -        edge e = new edge("product",
        +    private Edge newProductEdge(String u1, String v1, String u2, String v2) {
        +        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..4dfeb78 100644
        --- a/Gvisual/src/gvisual/GraphQueryEngine.java
        +++ b/Gvisual/src/gvisual/GraphQueryEngine.java
        @@ -22,13 +22,13 @@
          *     .results();
          *
          * // Find heavy edges of a specific type
        - * Set<edge> filtered = engine.edges()
        + * Set<Edge> filtered = engine.edges()
          *     .ofType("f")
          *     .withMinWeight(0.5f)
          *     .results();
          *
        - * // Combine node + edge filters: edges between high-degree nodes
        - * Set<edge> hubEdges = engine.edges()
        + * // Combine node + Edge filters: edges between high-degree nodes
        + * Set<Edge> hubEdges = engine.edges()
          *     .betweenNodes(engine.nodes().withMinDegree(5).results())
          *     .results();
          *
        @@ -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");
             }
         
        @@ -53,7 +53,7 @@ public GraphQueryEngine(Graph graph) {
         
             /**
              * Compile a regex pattern with safety checks: length limit and syntax validation.
        -     * Pre-compiling also avoids re-compilation on every vertex/edge evaluation.
        +     * Pre-compiling also avoids re-compilation on every vertex/Edge evaluation.
              *
              * @throws IllegalArgumentException if the pattern is too long or has invalid syntax
              */
        @@ -80,7 +80,7 @@ public NodeQuery nodes() {
             }
         
             /**
        -     * Start an edge query.
        +     * Start an Edge query.
              */
             public EdgeQuery edges() {
                 return new EdgeQuery(graph);
        @@ -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;
                 }
         
        @@ -169,10 +169,10 @@ public NodeQuery inSet(Set allowed) {
                     return this;
                 }
         
        -        /** Keep only nodes that have at least one edge of the given type. */
        +        /** 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 List> filters = new ArrayList<>();
        +        private final Graph graph;
        +        private final List> filters = new ArrayList<>();
         
        -        EdgeQuery(Graph graph) {
        +        EdgeQuery(Graph graph) {
                     this.graph = graph;
                 }
         
        @@ -315,13 +315,13 @@ public EdgeQuery temporal() {
                 }
         
                 /** Add a custom predicate filter. */
        -        public EdgeQuery where(Predicate predicate) {
        +        public EdgeQuery where(Predicate predicate) {
                     filters.add(predicate);
                     return this;
                 }
         
                 /** 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,16 +333,16 @@ 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())
        +                    .sorted(Comparator.comparing(Edge::getWeight).reversed())
                             .collect(Collectors.toList());
                 }
         
                 /** 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()));
        +            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..6676247 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;
        +    /** Graph reference for vertex‐paint Edge‐type lookup. */
        +    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) -> {
        +    public Transformer edgePaintTransformer() {
        +        return (Edge e) -> {
                         if (pathEdges != null && pathEdges.contains(e)) {
                             return Color.YELLOW;
                         }
        @@ -176,10 +176,10 @@ public Transformer vertexPaintTransformer() {
                         if (pathVertices != null && pathVertices.contains(vertex)) {
                             return Color.YELLOW;
                         }
        -                // Determine vertex colour based on connected edge types
        +                // 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);
        @@ -229,8 +229,8 @@ public Transformer vertexShapeTransformer() {
                     };
             }
         
        -    public Transformer edgeStrokeTransformer() {
        -        return (edge i) -> {
        +    public Transformer edgeStrokeTransformer() {
        +        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..196e257 100644
        --- a/Gvisual/src/gvisual/GraphSampler.java
        +++ b/Gvisual/src/gvisual/GraphSampler.java
        @@ -17,7 +17,7 @@
          *       on the selected nodes. Simple but may miss edges and fragment
          *       the sample.
          *   
      • Random Edge — uniformly samples edges; includes both - * endpoints. Preserves edge density better than node sampling.
      • + * endpoints. Preserves Edge density better than node sampling. *
      • Snowball / BFS — starts from seed nodes and explores * outward layer by layer. Produces connected, localized samples. * Good for community studies.
      • @@ -35,7 +35,7 @@ * GraphSampler sampler = new GraphSampler(graph); * // Sample 30% of nodes via random walk * SampleResult result = sampler.randomWalk(0.30, null, 0.15); - * Graph<String, edge> sample = result.getSample(); + * Graph<String, Edge> sample = result.getSample(); * System.out.println(result.getSummary()); *
        * @@ -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; @@ -96,8 +96,8 @@ public SampleResult randomNode(double fraction) { } /** - * Uniform random edge sampling. Selects edges uniformly at random - * and includes both endpoints of each selected edge. + * Uniform random Edge sampling. Selects edges uniformly at random + * and includes both endpoints of each selected Edge. * * @param fraction fraction of edges to sample (0.0, 1.0] * @return the sample result @@ -107,13 +107,13 @@ 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); + Edge e = edges.get(i); Collection endpoints = graph.getEndpoints(e); if (endpoints != null && endpoints.size() == 2) { Iterator it = endpoints.iterator(); @@ -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()); @@ -377,23 +377,23 @@ private SampleResult buildResult(Set sampledNodes, String strategy) { } /** - * Build a SampleResult from pre-selected edges (for edge sampling). + * 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..5f4a58c 100644 --- a/Gvisual/src/gvisual/GraphSimilarityAnalyzer.java +++ b/Gvisual/src/gvisual/GraphSimilarityAnalyzer.java @@ -19,7 +19,7 @@ * level. *
      • Entropy Profile Distance — L2 (Euclidean) distance between * normalised entropy vectors (degree entropy, Von Neumann entropy, - * neighbourhood entropy, edge type entropy, topological info content, + * neighbourhood entropy, Edge type entropy, topological info content, * random walk entropy rate). Captures multi-faceted structural * differences.
      • *
      • Similarity score — combined [0, 1] similarity derived from @@ -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..ce71a1b 100644 --- a/Gvisual/src/gvisual/GraphSparsificationAnalyzer.java +++ b/Gvisual/src/gvisual/GraphSparsificationAnalyzer.java @@ -5,15 +5,15 @@ import java.util.*; /** - * Graph Sparsification Analyzer — reduces edge count while preserving + * Graph Sparsification Analyzer — reduces Edge count while preserving * key structural properties of the graph. * *

        Capabilities

        *
          *
        • Spanning tree sparsification — minimum edges preserving connectivity
        • *
        • Edge importance scoring — betweenness, bridge detection, redundancy
        • - *
        • Random sparsification — probabilistic edge sampling with target ratio
        • - *
        • Threshold sparsification — weight-based edge filtering
        • + *
        • Random sparsification — probabilistic Edge sampling with target ratio
        • + *
        • Threshold sparsification — weight-based Edge filtering
        • *
        • Local sparsification — preserve top-k edges per vertex by weight
        • *
        • Importance-based sparsification — keep most structurally important edges
        • *
        • Quality metrics — connectivity, density, degree correlation grading
        • @@ -24,22 +24,22 @@ */ 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"); } this.graph = graph; } - /** Scores each edge by importance (0.0-1.0). Higher = more important. */ - public Map scoreEdgeImportance() { - Map scores = new LinkedHashMap(); + /** Scores each Edge by importance (0.0-1.0). Higher = more important. */ + public Map scoreEdgeImportance() { + Map scores = new LinkedHashMap(); if (graph.getEdgeCount() == 0) return scores; - Map betweenness = computeEdgeBetweenness(); - Set bridges = findBridges(); + Map betweenness = computeEdgeBetweenness(); + 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]++; @@ -91,7 +91,7 @@ private void bridgeDFS(String u, Map disc, Map bridgeDFS(nb, disc, low, parent, timer, bridges); low.put(u, Math.min(low.get(u), low.get(nb))); if (low.get(nb) > disc.get(u)) { - edge be = graph.findEdge(u, nb); + Edge be = graph.findEdge(u, nb); if (be != null) bridges.add(be); } } else if (!nb.equals(parent.get(u))) { @@ -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); @@ -136,17 +136,17 @@ private void ufUnion(Map p, Map r, String a, St else { p.put(b, a); r.put(a, r.get(a) + 1); } } - /** Random sparsification — keeps each edge with given probability. */ - public Graph randomSparsify(double keepProb, long seed) { + /** Random sparsification — keeps each Edge with given probability. */ + 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,24 +201,24 @@ 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(); - List> sorted = new ArrayList>(scores.entrySet()); - Collections.sort(sorted, (Map.Entry a, Map.Entry b) -> { + Map scores = scoreEdgeImportance(); + List> sorted = new ArrayList>(scores.entrySet()); + Collections.sort(sorted, (Map.Entry a, Map.Entry b) -> { return Double.compare(b.getValue(), a.getValue()); }); int keep = (int) Math.ceil(graph.getEdgeCount() * keepRatio); int cnt = 0; - for (Map.Entry entry : sorted) { + for (Map.Entry entry : sorted) { if (cnt >= keep) break; - edge e = entry.getKey(); + 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; @@ -292,9 +292,9 @@ private double pearson(double[] x, double[] y) { return (dx == 0 || dy == 0) ? 0 : num / Math.sqrt(dx * dy); } - private Map computeEdgeBetweenness() { - Map bet = new LinkedHashMap(); - for (edge e : graph.getEdges()) bet.put(e, 0.0); + private Map computeEdgeBetweenness() { + Map bet = new LinkedHashMap(); + for (Edge e : graph.getEdges()) bet.put(e, 0.0); for (String s : graph.getVertices()) { Stack stack = new Stack(); Map> pred = new HashMap>(); @@ -316,13 +316,13 @@ private Map computeEdgeBetweenness() { String w = stack.pop(); for (String vtx : pred.get(w)) { double c = (double) sigma.get(vtx) / sigma.get(w) * (1.0 + delta.get(w)); - edge e = graph.findEdge(vtx, w); + Edge e = graph.findEdge(vtx, w); if (e != null) bet.put(e, bet.get(e) + c); delta.put(vtx, delta.get(vtx) + c); } } } - 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++; @@ -426,12 +426,12 @@ public String generateReport() { if (best != null) sb.append(String.format(" Recommended: %s\n\n", best)); sb.append("── Top Important Edges ──\n"); - Map importance = scoreEdgeImportance(); - List> sorted = new ArrayList>(importance.entrySet()); - Collections.sort(sorted, (Map.Entry a, Map.Entry b) -> { return Double.compare(b.getValue(), a.getValue()); }); + Map importance = scoreEdgeImportance(); + List> sorted = new ArrayList>(importance.entrySet()); + Collections.sort(sorted, (Map.Entry a, Map.Entry b) -> { return Double.compare(b.getValue(), a.getValue()); }); for (int i = 0; i < Math.min(10, sorted.size()); i++) { - Map.Entry entry = sorted.get(i); - edge e = entry.getKey(); + Map.Entry entry = sorted.get(i); + Edge e = entry.getKey(); sb.append(String.format(" %s — %s (importance: %.3f)\n", e.getVertex1(), e.getVertex2(), entry.getValue())); } } diff --git a/Gvisual/src/gvisual/GraphStats.java b/Gvisual/src/gvisual/GraphStats.java index 93e4113..c0d803d 100644 --- a/Gvisual/src/gvisual/GraphStats.java +++ b/Gvisual/src/gvisual/GraphStats.java @@ -5,19 +5,19 @@ /** * Computes network analysis metrics for a JUNG graph. - * Provides node/edge counts, per-category breakdowns, density, + * Provides node/Edge counts, per-category breakdowns, density, * degree statistics, and identifies hub nodes. * * @author zalenix */ 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; @@ -188,12 +188,12 @@ public int getIsolatedNodeCount() { } /** - * Cached edge weight statistics computed once. + * Cached Edge weight statistics computed once. */ private double cachedTotalWeight = -1.0; /** - * Average edge weight across all visible edges. + * Average Edge weight across all visible edges. * Caches the total weight sum to avoid re-iterating edges if called * multiple times. */ @@ -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..72c63cf 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); @@ -240,7 +240,7 @@ public String getStructuralObservations() { // Average weight double avgWeight = stats.getAverageWeight(); if (avgWeight > 0) { - observations.add(String.format("Average edge weight is %.2f, indicating %s interactions.", + observations.add(String.format("Average Edge weight is %.2f, indicating %s interactions.", avgWeight, avgWeight > 100 ? "strong" : avgWeight > 30 ? "moderate" : "light")); } diff --git a/Gvisual/src/gvisual/GraphSymmetryAnalyzer.java b/Gvisual/src/gvisual/GraphSymmetryAnalyzer.java index e6371f1..26d54aa 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; + /** Lazily computed Edge orbits. */ + private List> edgeOrbits; - public GraphSymmetryAnalyzer(Graph graph) { + public GraphSymmetryAnalyzer(Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph must not be null"); } @@ -149,10 +149,10 @@ private void ensureComputed() { } orbits = new ArrayList<>(groups.values()); - // Build edge orbits: two edges are equivalent if their endpoint + // 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); @@ -213,16 +213,16 @@ public Set getOrbitOf(String vertex) { // ------------------------------------------------------------------ /** - * Returns the list of edge orbits. Edges whose endpoint orbit-pairs + * 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); } /** - * Returns the number of distinct edge orbits. + * Returns the number of distinct Edge orbits. */ public int getEdgeOrbitCount() { ensureComputed(); @@ -243,7 +243,7 @@ public boolean isVertexTransitive() { } /** - * A graph is edge-transitive if all edges belong to a single orbit. + * A graph is Edge-transitive if all edges belong to a single orbit. */ public boolean isEdgeTransitive() { if (graph.getEdgeCount() == 0) return true; @@ -253,7 +253,7 @@ public boolean isEdgeTransitive() { /** * A graph is symmetric (arc-transitive) if it is both vertex-transitive - * and edge-transitive. This is a necessary (not sufficient) condition — + * and Edge-transitive. This is a necessary (not sufficient) condition — * colour refinement may over-approximate. */ public boolean isSymmetric() { 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..5b850d6 100644 --- a/Gvisual/src/gvisual/GraphUtils.java +++ b/Gvisual/src/gvisual/GraphUtils.java @@ -22,14 +22,14 @@ public final class GraphUtils { private GraphUtils() { /* utility class */ } /** - * Returns the vertex at the other end of an edge from the given vertex. + * Returns the vertex at the other end of an Edge from the given vertex. * - * @param e the edge + * @param e the Edge * @param current the vertex we're "standing on" * @return the other endpoint, or {@code null} if {@code current} is not - * an endpoint of the edge + * 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; @@ -334,23 +334,23 @@ public static int cycleRankOfSubgraph( // ── Graph copy ────────────────────────────────────────────────────── /** - * Creates a deep copy of a graph, preserving all vertices, edges, edge + * Creates a deep copy of a graph, preserving all vertices, edges, Edge * types, weights, and labels. * * @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; @@ -561,14 +561,14 @@ public DijkstraResult(Map dist, Map prev) { * *

          Uses a visited set to avoid re-processing settled nodes, and * immutable PQ entries to handle Java's non-updatable PriorityQueue. - * Edge weights are taken from {@link edge#getWeight()}; non-positive + * Edge weights are taken from {@link Edge#getWeight()}; non-positive * weights default to 1.0.

          * * @param graph the JUNG graph * @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(); } @@ -670,7 +670,7 @@ public static Collection neighborsOf( /** * Directed adjacency structure: vertices with successor and predecessor * maps. Extracted from {@link TopologicalSortAnalyzer} for reuse by - * any analyzer that needs directed-edge traversal. + * any analyzer that needs directed-Edge traversal. */ public static final class DirectedAdj { /** All vertices in the graph. */ @@ -690,14 +690,14 @@ public DirectedAdj(Set vertices, } /** - * Builds directed adjacency maps from a graph. Each edge is interpreted + * Builds directed adjacency maps from a graph. Each Edge is interpreted * as vertex1 → vertex2. * * @param graph the JUNG graph * @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..45bde08 100644 --- a/Gvisual/src/gvisual/GrowthRateAnalyzer.java +++ b/Gvisual/src/gvisual/GrowthRateAnalyzer.java @@ -4,7 +4,7 @@ import java.util.*; /** - * Tracks how graph metrics change over time: node count, edge count, + * Tracks how graph metrics change over time: node count, Edge count, * density, and average clustering coefficient across time windows. * Useful for identifying growth phases, stability periods, and * network degradation. @@ -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); @@ -85,15 +85,15 @@ public List analyze() { /** * Computes the overall growth trend as a simple metric: * positive = growing, negative = shrinking, near zero = stable. - * Based on linear regression of edge count over windows. + * Based on linear regression of Edge count over windows. * - * @return slope of edge count over time windows + * @return slope of Edge count over time windows */ public double edgeGrowthRate() { List snapshots = analyze(); if (snapshots.size() < 2) return 0.0; - // Simple linear regression on edge count + // Simple linear regression on Edge count int n = snapshots.size(); double sumX = 0, sumY = 0, sumXY = 0, sumXX = 0; for (int i = 0; i < n; i++) { @@ -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..321c933 100644 --- a/Gvisual/src/gvisual/HierarchicalLayout.java +++ b/Gvisual/src/gvisual/HierarchicalLayout.java @@ -16,9 +16,9 @@ *
        • Layer assignment — places each node in a layer based on its * longest-path depth from source nodes.
        • *
        • Crossing reduction — reorders nodes within each layer to - * minimize edge crossings (barycenter heuristic, multi-pass).
        • + * minimize Edge crossings (barycenter heuristic, multi-pass). *
        • X-coordinate assignment — positions nodes within layers - * to minimize edge bends and balance spacing.
        • + * to minimize Edge bends and balance spacing. * * *

          Features

          @@ -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( @@ -238,8 +238,8 @@ private Map> removeCycles( dag.get(be[0]).remove(be[1]); dag.get(be[1]).add(be[0]); - // Track the original edge objects - for (edge e : graph.getEdges()) { + // Track the original Edge objects + for (Edge e : graph.getEdges()) { if (be[0].equals(e.getVertex1()) && be[1].equals(e.getVertex2())) { reversedEdges.add(e); } @@ -507,7 +507,7 @@ private int countEdgeCrossings(Map> succ) { } } - // Count crossings: edge (u1,v1) crosses (u2,v2) if + // Count crossings: Edge (u1,v1) crosses (u2,v2) if // (u1 < u2 && v1 > v2) or (u1 > u2 && v1 < v2) for (int a = 0; a < edges.size(); a++) { for (int b = a + 1; b < edges.size(); b++) { @@ -630,7 +630,7 @@ public List getCriticalPath() { } /** - * Gets the number of edge crossings in the layout. + * Gets the number of Edge crossings in the layout. * * @throws IllegalStateException if compute() has not been called */ @@ -642,10 +642,10 @@ public int getEdgeCrossings() { /** * Gets edges that were reversed to break cycles. * - * @return set of edge objects that were reversed + * @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..a7e14ea 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; /** @@ -56,8 +56,8 @@ public enum NodeState { private final Map> neighborCache; /** - * Pre-cached edge weights: "from\0to" → weight. - * Only entries with edge weight in (0, 1] are stored; missing keys + * Pre-cached Edge weights: "from\0to" → weight. + * Only entries with Edge weight in (0, 1] are stored; missing keys * mean "use default probability". Avoids O(degree) findEdge() lookups * that dominated Monte Carlo hot loops. */ @@ -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"); } @@ -112,14 +112,14 @@ private Map> buildNeighborCache() { } /** - * Pre-caches edge weights that override the default probability. + * Pre-caches Edge weights that override the default probability. * Only stores edges where weight is in (0, 1] — the range that * getEdgeProbability would use instead of the default. Key format: * "from\0to" (null-char separator — never appears in vertex IDs). */ 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); @@ -482,11 +482,11 @@ public VaccinationStrategy findVaccinationTargets(int k) { targetSet.add(degrees.get(i).getKey()); } - // Count distinct edges blocked: an edge is blocked if at least one + // Count distinct edges blocked: an Edge is blocked if at least one // 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..4ff8c35 100644 --- a/Gvisual/src/gvisual/InteractiveHtmlExporter.java +++ b/Gvisual/src/gvisual/InteractiveHtmlExporter.java @@ -19,7 +19,7 @@ *
        • Hover tooltips showing node ID, degree, and neighbor count
        • *
        • Click a node to highlight its ego network
        • *
        • Search/filter nodes by ID
        • - *
        • Legend for edge types
        • + *
        • Legend for Edge types
        • *
        • Statistics sidebar with graph metrics
        • *
        • Dark/light theme toggle
        • *
        @@ -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)) { @@ -399,7 +399,7 @@ private String generateJs() { + "})();\n"; } - /** Maps edge type codes to human-readable names. */ + /** Maps Edge type codes to human-readable names. */ private static String typeName(String type) { if (type == null) return "Unknown"; switch (type) { @@ -412,7 +412,7 @@ private static String typeName(String type) { } } - /** Maps edge type codes to CSS colors. */ + /** Maps Edge type codes to CSS colors. */ private static String typeColor(String type) { if (type == null) return "#999"; switch (type) { diff --git a/Gvisual/src/gvisual/JsonGraphExporter.java b/Gvisual/src/gvisual/JsonGraphExporter.java index a16b2da..830e013 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,9 +173,9 @@ 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); + Edge e = sortedEdges.get(i); sb.append(indent2).append("{"); sb.append("\"source\":").append(sep).append(jsonString(e.getVertex1())).append(",").append(sep); sb.append("\"target\":").append(sep).append(jsonString(e.getVertex2())).append(",").append(sep); diff --git a/Gvisual/src/gvisual/KCoreDecomposition.java b/Gvisual/src/gvisual/KCoreDecomposition.java index 1a18044..1ad5908 100644 --- a/Gvisual/src/gvisual/KCoreDecomposition.java +++ b/Gvisual/src/gvisual/KCoreDecomposition.java @@ -27,7 +27,7 @@ *
      • Degeneracy — the maximum coreness value (also the graph's * degeneracy number).
      • *
      • Core shells — grouping of vertices by their coreness value.
      • - *
      • Core density profile — edge density within each k-core.
      • + *
      • Core density profile — Edge density within each k-core.
      • *
      • Cohesion score — a 0–100 measure of how "core-heavy" the graph is * (what fraction of vertices are in the innermost core).
      • *
      @@ -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"); } @@ -295,7 +295,7 @@ public String toString() { } /** - * Computes edge density for each k-core (from k=0 to degeneracy). + * Computes Edge density for each k-core (from k=0 to degeneracy). * The density should increase as k grows, since higher cores are * progressively denser subgraphs. * @@ -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..3f4be7a 100644 --- a/Gvisual/src/gvisual/KTrussAnalyzer.java +++ b/Gvisual/src/gvisual/KTrussAnalyzer.java @@ -7,11 +7,11 @@ /** * K-Truss Decomposition — identifies cohesive subgraphs based on triangle - * support. Each edge receives a truss number equal to the highest + * support. Each Edge receives a truss number equal to the highest * k-truss it belongs to: * *
      - * A k-truss is a maximal subgraph where every edge participates in + * A k-truss is a maximal subgraph where every Edge participates in * at least (k − 2) triangles within that subgraph. *
      * @@ -21,10 +21,10 @@ * *

      Algorithm (peeling, O(m · t_max))

      *
        - *
      1. Count triangle support for every edge.
      2. + *
      3. Count triangle support for every Edge.
      4. *
      5. Starting from k = 2, iteratively remove edges with support < k − 2.
      6. - *
      7. When an edge is removed, update triangle counts for affected edges.
      8. - *
      9. An edge's truss number is the k at which it was removed.
      10. + *
      11. When an Edge is removed, update triangle counts for affected edges.
      12. + *
      13. An Edge's truss number is the k at which it was removed.
      14. *
      * *

      References:

      @@ -37,9 +37,9 @@ */ public class KTrussAnalyzer { - private final Graph graph; - private Map trussNumbers; - private Map triangleSupport; + private final Graph graph; + private Map trussNumbers; + private Map triangleSupport; private int maxTrussNumber; private boolean computed; @@ -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) { + // Step 1: compute initial triangle support for each Edge + 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; @@ -93,8 +93,8 @@ private void compute() { if (neighborsV.contains(w)) { // Triangle u-v-w found triangleSupport.merge(e, 1, Integer::sum); - edge uw = findEdge(remainingEdges, u, w); - edge vw = findEdge(remainingEdges, v, w); + Edge uw = findEdge(remainingEdges, u, w); + Edge vw = findEdge(remainingEdges, v, w); if (uw != null) { triangleSupport.merge(uw, 1, Integer::sum); edgeTrianglePartners.get(e).add(uw); @@ -109,16 +109,16 @@ private void compute() { } } - // Correct for double-counting: each triangle is found 3 times (once per edge) - // but each edge in a triangle gets counted twice for neighbors + // Correct for double-counting: each triangle is found 3 times (once per Edge) + // 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) { + // Enumerate triangles properly: for each Edge (u,v), count common neighbors + for (Edge e : remainingEdges) { String u = getEndpoint1(e); String v = getEndpoint2(e); if (u == null || v == null) continue; @@ -136,25 +136,25 @@ private void compute() { } // Step 2: Peeling — iteratively remove edges with lowest support - Set active = new LinkedHashSet<>(remainingEdges); - Map support = new LinkedHashMap<>(triangleSupport); + Set active = new LinkedHashSet<>(remainingEdges); + Map support = new LinkedHashMap<>(triangleSupport); int k = 2; while (!active.isEmpty()) { boolean changed = true; while (changed) { changed = false; - Iterator it = active.iterator(); - List toRemove = new ArrayList<>(); + Iterator it = active.iterator(); + List toRemove = new ArrayList<>(); while (it.hasNext()) { - edge e = it.next(); + Edge e = it.next(); if (support.getOrDefault(e, 0) < k - 2) { toRemove.add(e); } } - 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; @@ -186,7 +186,7 @@ private void compute() { String otherEnd = ou.equals(shared) ? ov : ou; String eOtherEnd = getEndpoint1(e).equals(shared) ? getEndpoint2(e) : getEndpoint1(e); - // Check if there's an active edge between otherEnd and eOtherEnd + // Check if there's an active Edge between otherEnd and eOtherEnd if (hasActiveEdge(active, otherEnd, eOtherEnd)) { support.merge(other, -1, Integer::sum); } @@ -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++; @@ -212,12 +212,12 @@ private void compute() { } /** - * Gets the truss number of a specific edge. + * Gets the truss number of a specific Edge. * - * @param e the edge - * @return the truss number, or 0 if edge not in graph + * @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,13 +239,13 @@ 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()) { + for (Map.Entry entry : trussNumbers.entrySet()) { if (entry.getValue() >= k) { - edge e = entry.getKey(); + Edge e = entry.getKey(); String u = getEndpoint1(e); String v = getEndpoint2(e); if (u != null && v != null) { @@ -260,7 +260,7 @@ public Graph getKTruss(int k) { } /** - * Returns the distribution of edge truss numbers as a histogram. + * Returns the distribution of Edge truss numbers as a histogram. * * @return map from truss number to count of edges with that truss number */ @@ -274,13 +274,13 @@ public Map getTrussDistribution() { } /** - * Gets the triangle support count for an edge (number of triangles - * containing that edge in the original graph). + * Gets the triangle support count for an Edge (number of triangles + * containing that Edge in the original graph). * - * @param e the edge - * @return number of triangles containing this edge + * @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,10 +291,10 @@ 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<>(); - for (Map.Entry entry : trussNumbers.entrySet()) { + Map> hierarchy = new TreeMap<>(); + for (Map.Entry entry : trussNumbers.entrySet()) { hierarchy.computeIfAbsent(entry.getValue(), k -> new ArrayList<>()) .add(entry.getKey()); } @@ -319,11 +319,11 @@ public List compareTrussVsCore() { report.add(String.format("Graph degeneracy (max core): %d", kcore.getDegeneracy())); report.add(""); - // For each vertex, compute its "truss participation" — max truss of any incident edge + // For each vertex, compute its "truss participation" — max truss of any incident Edge 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..676b24a 100644 --- a/Gvisual/src/gvisual/LineGraphAnalyzer.java +++ b/Gvisual/src/gvisual/LineGraphAnalyzer.java @@ -10,7 +10,7 @@ * *

      The line graph L(G) is a graph where:

      *
        - *
      • Each edge of G becomes a vertex in L(G)
      • + *
      • Each Edge of G becomes a vertex in L(G)
      • *
      • Two vertices in L(G) are adjacent if and only if their corresponding * edges in G share a common endpoint
      • *
      @@ -24,20 +24,20 @@ *
    • Edge adjacency analysis — neighborhoods, central edges
    • *
    • Iterated line graphs — L²(G), L³(G) with convergence analysis
    • *
    • Matching via independent set — maximal matching in G through L(G)
    • - *
    • Vertex edge-cliques — clique decomposition of L(G)
    • + *
    • Vertex Edge-cliques — clique decomposition of L(G)
    • *
    * * @author zalenix */ 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,13 +53,13 @@ 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); + Edge e = edges.get(i); String label = edgeLabel(e); lineGraph.addVertex(label); vertexToEdge.put(label, e); @@ -68,12 +68,12 @@ private void buildLineGraph() { for (int i = 0; i < edges.size(); i++) { for (int j = i + 1; j < edges.size(); j++) { - edge e1 = edges.get(i); - edge e2 = edges.get(j); + Edge e1 = edges.get(i); + Edge e2 = edges.get(j); 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..f53f08a 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"); } @@ -248,7 +248,7 @@ public PredictionResult predictEnsemble(int topK) { }; /** - * Holds the results of enumerating all candidate (non-edge) vertex pairs, + * Holds the results of enumerating all candidate (non-Edge) vertex pairs, * along with precomputed adjacency and common-neighbor sets. This lets * {@link #predict} and {@link #predictEnsemble} share the expensive O(V²) * pair enumeration, adjacency construction, and common-neighbor @@ -277,7 +277,7 @@ private static class PairEvaluation { } /** - * Enumerates all non-edge vertex pairs, builds adjacency, and computes + * Enumerates all non-Edge vertex pairs, builds adjacency, and computes * common neighbors for each pair. Called once by predict/predictEnsemble. */ private PairEvaluation evaluatePairs() { diff --git a/Gvisual/src/gvisual/LouvainCommunityDetector.java b/Gvisual/src/gvisual/LouvainCommunityDetector.java index 5beec01..47ccb7f 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; @@ -418,7 +418,7 @@ private boolean phase1(List> adj, double[] degree, int curC = community[i]; double ki = degree[i]; - // Aggregate neighbor edge weights by community, reusing nw map + // Aggregate neighbor Edge weights by community, reusing nw map touchedCount = 0; for (Map.Entry e : adj.get(i).entrySet()) { int cj = community[e.getKey()]; diff --git a/Gvisual/src/gvisual/MSTPanelController.java b/Gvisual/src/gvisual/MSTPanelController.java index 4afb061..222d582 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; @@ -116,12 +116,12 @@ private void runComputation() { stats.append(String.format("Avg Weight: %.1f
    ", result.getAverageWeight())); if (result.getHeaviestEdge() != null) { - edge heavy = result.getHeaviestEdge(); + Edge heavy = result.getHeaviestEdge(); stats.append(String.format("Bottleneck: %s\u2194%s (%.1f)
    ", heavy.getVertex1(), heavy.getVertex2(), heavy.getWeight())); } if (result.getLightestEdge() != null) { - edge light = result.getLightestEdge(); + Edge light = result.getLightestEdge(); stats.append(String.format("Lightest: %s\u2194%s (%.1f)
    ", light.getVertex1(), light.getVertex2(), light.getWeight())); } diff --git a/Gvisual/src/gvisual/Main.java b/Gvisual/src/gvisual/Main.java index 9d0028e..05a901f 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; @@ -43,7 +43,7 @@ * visualisation and analysis tool built on JUNG (Java Universal Network/Graph). * *

    Overview

    - *

    Loads edge-list data (from flat files or a database via {@link app.Network}), + *

    Loads Edge-list data (from flat files or a database via {@link app.Network}), * builds an {@link edu.uci.ics.jung.graph.UndirectedSparseGraph}, and renders it * in a Swing {@link edu.uci.ics.jung.visualization.VisualizationViewer} with * interactive controls for filtering, layout, analysis, and export.

    @@ -60,7 +60,7 @@ *
  • Graph algorithms: shortest path (hop/weight), minimum spanning tree, * community detection (Louvain), articulation points/bridges, ego-network * extraction, PageRank, centrality, and many more via the analysis menu.
  • - *
  • Export: GraphML, DOT, GEXF, SVG, PNG, CSV edge-list, interactive HTML, + *
  • Export: GraphML, DOT, GEXF, SVG, PNG, CSV Edge-list, interactive HTML, * and network reports through {@link ExportActions} and {@link ToolbarBuilder}.
  • * * @@ -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; @@ -227,10 +227,10 @@ public Main() throws FileNotFoundException, Exception { } /** - * Returns the edge list for the given edge type. + * 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; @@ -242,7 +242,7 @@ private List getEdgeList(EdgeType type) { } /** - * Returns whether the given edge type code is currently visible + * Returns whether the given Edge type code is currently visible * (its checkbox is selected). */ private boolean isEdgeTypeVisible(String typeCode) { @@ -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) { @@ -404,7 +404,7 @@ private ChangeListener createGraphRefreshListener(final JSlider slider) { } /** - * Holds the UI components for a single edge-type category row. + * Holds the UI components for a single Edge-type category row. */ private static class CategoryRow { final JCheckBox checkbox; @@ -431,17 +431,17 @@ private static class CategoryRow { /** * Creates a fully-wired category row (checkbox + label + sliders + settings - * button) for the given edge type. This replaces the five near-identical + * button) for the given Edge type. This replaces the five near-identical * blocks that previously lived in {@code initializeCategoryPanel()}. * - * @param type the edge type this row controls - * @param edgeList the corresponding edge list (e.g. {@code friendEdges}) + * @param type the Edge type this row controls + * @param edgeList the corresponding Edge list (e.g. {@code friendEdges}) * @param labelText the display text for the label * @param durMax maximum value for the duration slider * @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); @@ -579,9 +579,9 @@ public void addGraph() throws ParserConfigurationException, IOException, SAXExce g = parseResult.getGraph(); - // Populate classified edge lists from parse result + // 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,13 +730,13 @@ 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(); } }); } /** - * Returns a human-readable label for edge type codes. + * Returns a human-readable label for Edge type codes. */ private String getDominantLabel(String typeCode) { EdgeType type = EdgeType.fromCode(typeCode); @@ -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(); } }); } @@ -1067,7 +1067,7 @@ private void paintCategoryPanel() { /** * initialize the category panel â€" creates one {@link CategoryRow} - * per edge type using the shared {@code createCategoryRow()} helper. + * per Edge type using the shared {@code createCategoryRow()} helper. */ public final void initializeCategoryPanel() { categoryRows = new CategoryRow[5]; @@ -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..f8e0447 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,9 +186,9 @@ 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). + // 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..246e039 100644 --- a/Gvisual/src/gvisual/MinimumSpanningTree.java +++ b/Gvisual/src/gvisual/MinimumSpanningTree.java @@ -15,7 +15,7 @@ *

    Features:

    *
      *
    • Kruskal's algorithm with path compression + union by rank
    • - *
    • MST statistics (total weight, edge count, component count)
    • + *
    • MST statistics (total weight, Edge count, component count)
    • *
    • Per-component breakdown (vertices, edges, weight)
    • *
    • Edge type distribution within the MST
    • *
    • Programmatic API for all results
    • @@ -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"); } @@ -49,31 +49,31 @@ public MSTResult compute() { if (vertexCount == 0) { return new MSTResult( - Collections.emptyList(), + Collections.emptyList(), Collections.emptyList(), 0, 0.0f, 0, vertexCount); } // 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); - if (compEdges == null) compEdges = Collections.emptyList(); + 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; } @@ -248,13 +248,13 @@ public boolean isConnected() { } /** - * Get edge type distribution in the MST. + * Get Edge type distribution in the MST. * - * @return map of edge type → count + * @return map of Edge type → count */ 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); @@ -278,13 +278,13 @@ public String getSummary() { } /** - * Get the heaviest edge in the MST (bottleneck). + * Get the heaviest Edge in the MST (bottleneck). * - * @return the heaviest edge, or null if MST is empty + * @return the heaviest Edge, or null if MST is empty */ - public edge getHeaviestEdge() { - edge heaviest = null; - for (edge e : edges) { + public Edge getHeaviestEdge() { + Edge heaviest = null; + for (Edge e : edges) { if (heaviest == null || e.getWeight() > heaviest.getWeight()) { heaviest = e; } @@ -293,13 +293,13 @@ public edge getHeaviestEdge() { } /** - * Get the lightest edge in the MST. + * Get the lightest Edge in the MST. * - * @return the lightest edge, or null if MST is empty + * @return the lightest Edge, or null if MST is empty */ - public edge getLightestEdge() { - edge lightest = null; - for (edge e : edges) { + public Edge getLightestEdge() { + Edge lightest = null; + for (Edge e : edges) { if (lightest == null || e.getWeight() < lightest.getWeight()) { lightest = e; } @@ -308,7 +308,7 @@ public edge getLightestEdge() { } /** - * Get the average edge weight in the MST. + * Get the average Edge weight in the MST. * * @return average weight, or 0 if no edges */ @@ -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; } @@ -350,13 +350,13 @@ public static class MSTComponent { public int getSize() { return vertices.size(); } /** - * Get the dominant edge type in this component's MST. + * Get the dominant Edge type in this component's MST. * - * @return the most common edge type, or null if empty + * @return the most common Edge type, or null if empty */ 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..f692d2e 100644 --- a/Gvisual/src/gvisual/NetworkFlowAnalyzer.java +++ b/Gvisual/src/gvisual/NetworkFlowAnalyzer.java @@ -8,8 +8,8 @@ * vertex using the Edmonds–Karp algorithm (BFS-based Ford–Fulkerson). * *

      Algorithm

      - *

      Treats every undirected edge as two directed arcs with capacity equal to - * the edge weight (default 1.0 for unweighted edges). Repeatedly finds the + *

      Treats every undirected Edge as two directed arcs with capacity equal to + * the Edge weight (default 1.0 for unweighted edges). Repeatedly finds the * shortest augmenting path via BFS and pushes as much flow as possible along * it, until no more augmenting paths exist.

      * @@ -22,7 +22,7 @@ *

      Analytics

      *
        *
      • Max flow value — the maximum amount of flow from source to sink.
      • - *
      • Flow assignment — per-edge flow values.
      • + *
      • Flow assignment — per-Edge flow values.
      • *
      • Min cut — the set of edges forming the minimum cut (max-flow * min-cut theorem).
      • *
      • Bottleneck edges — fully saturated edges on augmenting paths.
      • @@ -38,7 +38,7 @@ */ public class NetworkFlowAnalyzer { - private final Graph graph; + private final Graph graph; // Residual capacities: directedKey -> remaining capacity private Map, Double> residualCapacity; @@ -48,8 +48,8 @@ public class NetworkFlowAnalyzer { private Map> residualAdj; // Original capacities private Map, Double> capacity; - // Edge lookup: directedKey -> original edge (null for reverse arcs) - private Map, edge> edgeLookup; + // Edge lookup: directedKey -> original Edge (null for reverse arcs) + private Map, Edge> edgeLookup; private String source; private String sink; @@ -59,11 +59,11 @@ public class NetworkFlowAnalyzer { /** * Creates a new NetworkFlowAnalyzer for the given graph. * - * @param graph the JUNG graph (treated as undirected; each edge becomes + * @param graph the JUNG graph (treated as undirected; each Edge becomes * 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"); } @@ -163,16 +163,16 @@ public String getSink() { } /** - * Returns the flow on each original edge. - * The map key format is "v1->v2" for each edge direction. + * Returns the flow on each original Edge. + * The map key format is "v1->v2" for each Edge direction. * Only edges with positive flow are included. * - * @return unmodifiable map of edge direction to flow value + * @return unmodifiable map of Edge direction to flow value */ 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()); @@ -190,7 +190,7 @@ public Map getEdgeFlows() { } /** - * Returns the flow value on a specific edge (by its endpoints). + * Returns the flow value on a specific Edge (by its endpoints). * Returns the net flow in the v1→v2 direction (negative if reverse). * * @param v1 first endpoint @@ -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); @@ -295,14 +295,14 @@ public List getBottleneckEdges() { } /** - * Returns the total capacity of the network (sum of all edge capacities). + * Returns the total capacity of the network (sum of all Edge capacities). * * @return total network capacity */ 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); @@ -580,7 +580,7 @@ private void buildResidualGraph() { List fwd = directedKey(v1, v2); List rev = directedKey(v2, v1); - // Each undirected edge → two directed arcs + // Each undirected Edge → two directed arcs residualCapacity.put(fwd, residualCapacity.getOrDefault(fwd, 0.0) + cap); residualCapacity.put(rev, @@ -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..69e5115 100644 --- a/Gvisual/src/gvisual/NetworkReportGenerator.java +++ b/Gvisual/src/gvisual/NetworkReportGenerator.java @@ -33,26 +33,26 @@ */ 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(); - this.classmateEdges = classmateEdges != null ? classmateEdges : Collections.emptyList(); - this.strangerEdges = strangerEdges != null ? strangerEdges : Collections.emptyList(); - this.studyGEdges = studyGEdges != null ? studyGEdges : Collections.emptyList(); + this.friendEdges = friendEdges != null ? friendEdges : Collections.emptyList(); + this.fsEdges = fsEdges != null ? fsEdges : Collections.emptyList(); + this.classmateEdges = classmateEdges != null ? classmateEdges : Collections.emptyList(); + this.strangerEdges = strangerEdges != null ? strangerEdges : Collections.emptyList(); + this.studyGEdges = studyGEdges != null ? studyGEdges : Collections.emptyList(); } /** Set the report title. */ @@ -329,7 +329,7 @@ private String buildDegreeHistogram(Map dist, int maxDeg) { } private String buildPieChart(int[] counts, String[] names, String[] colors, int total) { - if (total == 0) return "

        No edge data

        "; + if (total == 0) return "

        No Edge data

        "; StringBuilder svg = new StringBuilder(); int size = 300; diff --git a/Gvisual/src/gvisual/NetworkRoleClassifier.java b/Gvisual/src/gvisual/NetworkRoleClassifier.java index 95836c2..c10b8ae 100644 --- a/Gvisual/src/gvisual/NetworkRoleClassifier.java +++ b/Gvisual/src/gvisual/NetworkRoleClassifier.java @@ -17,7 +17,7 @@ *
      • Bridge — high betweenness but moderate/low degree; spans communities
      • *
      • Local Hub — high degree + high clustering; leaders of tight clusters
      • *
      • Connector — moderate degree + moderate betweenness; links sub-groups
      • - *
      • Peripheral — low degree + low centrality; edge of the network
      • + *
      • Peripheral — low degree + low centrality; Edge of the network
      • *
      • Isolate — degree 0; disconnected from the network
      • *
      * @@ -58,7 +58,7 @@ public enum StructuralRole { BRIDGE("Bridge", "High betweenness but moderate degree; spans communities"), LOCAL_HUB("Local Hub", "High degree + high clustering; cluster leader"), CONNECTOR("Connector", "Moderate degree + moderate betweenness; links sub-groups"), - PERIPHERAL("Peripheral", "Low degree + low centrality; network edge"), + PERIPHERAL("Peripheral", "Low degree + low centrality; network Edge"), ISOLATE("Isolate", "Degree 0; disconnected from the network"); private final String label; @@ -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..d6ad5df 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"); } @@ -377,7 +377,7 @@ private void computeDegreeCentrality() { * source (V sources × V entries each = V² total), avoids Integer/Double * boxing, and provides better cache locality for the inner BFS loop. * Predecessor lists are still object-based but are allocated only when - * an edge is discovered (lazy), not pre-allocated for every vertex.

      + * an Edge is discovered (lazy), not pre-allocated for every vertex.

      * *

      Betweenness: Brandes (2001), O(V·E) for unweighted graphs, normalized * by (V-1)(V-2) for undirected. Closeness: Wasserman-Faust normalization @@ -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..3ae4d10 100644 --- a/Gvisual/src/gvisual/PageRankAnalyzer.java +++ b/Gvisual/src/gvisual/PageRankAnalyzer.java @@ -24,7 +24,7 @@ *

    • Repeat until convergence (L1 norm < tolerance) or max iterations reached
    • * * - *

      For undirected graphs, each edge counts as a bidirectional link. + *

      For undirected graphs, each Edge counts as a bidirectional link. * Dangling nodes (degree 0) distribute their rank uniformly to all nodes.

      * * @author zalenix @@ -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..9839096 100644 --- a/Gvisual/src/gvisual/PlanarGraphAnalyzer.java +++ b/Gvisual/src/gvisual/PlanarGraphAnalyzer.java @@ -10,7 +10,7 @@ *

      Features

      *
        *
      • Planarity testing — Euler's formula check (necessary) plus - * Boyer–Myrvold-inspired edge-addition planarity via DFS embedding
      • + * Boyer–Myrvold-inspired Edge-addition planarity via DFS embedding *
      • Face enumeration — walks around a combinatorial planar embedding * to list all faces (including the outer/unbounded face)
      • *
      • Dual graph — constructs the face-adjacency dual for a planar graph
      • @@ -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(); @@ -197,7 +197,7 @@ public static PlanarityResult testPlanarity(Graph graph) { if (V == 2) { boolean ok = E <= 1; return new PlanarityResult(ok, V, E, C, - ok ? "trivially planar (2 vertices)" : "multi-edge exceeds bound"); + ok ? "trivially planar (2 vertices)" : "multi-Edge exceeds bound"); } // Euler bound: E ≤ 3V - 6 for simple connected planar graph with V≥3 if (V >= 3 && E > 3 * V - 6) { @@ -205,7 +205,7 @@ public static PlanarityResult testPlanarity(Graph graph) { String.format("fails Euler bound: E=%d > 3V-6=%d", E, 3 * V - 6)); } - // For small graphs, attempt embedding via edge-addition + // For small graphs, attempt embedding via Edge-addition Map> adj = GraphUtils.buildAdjacencyMap(graph); boolean planar = attemptPlanarEmbedding(adj, graph); @@ -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; @@ -233,7 +233,7 @@ public static List enumerateFaces(Graph graph) { return faces; } - // Trace faces using the "next-edge" walk on the combinatorial embedding + // Trace faces using the "next-Edge" walk on the combinatorial embedding Set visitedDarts = new HashSet(); List faces = new ArrayList(); int faceId = 0; @@ -292,13 +292,13 @@ public static List enumerateFaces(Graph graph) { /** * Constructs the dual graph of a planar graph. * Each face becomes a node; two nodes are adjacent if their faces - * share an edge. + * share an Edge. */ - public static DualGraph buildDualGraph(Graph graph) { + public static DualGraph buildDualGraph(Graph graph) { List faces = enumerateFaces(graph); if (faces == null) return null; - // Build edge → face mapping + // Build Edge → face mapping Map> edgeToFaces = new HashMap>(); for (Face f : faces) { List verts = f.getVertices(); @@ -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; @@ -392,7 +392,7 @@ public static PlanarityReport analyze(Graph graph) { // Internal helpers // =============================================================== - /** Exhaustive minor check for small graphs using DFS over all possible edge contractions. */ + /** Exhaustive minor check for small graphs using DFS over all possible Edge contractions. */ private static boolean exhaustiveMinorCheck(Map> g) { // Clean up boolean changed = true; @@ -415,7 +415,7 @@ private static boolean exhaustiveMinorCheck(Map> g) { if (g.size() == 6 && isK33(g)) return true; if (g.size() > 12) return false; // too expensive for exhaustive - // Try each edge contraction + // Try each Edge contraction for (String u : new ArrayList(g.keySet())) { for (String v : new ArrayList(g.get(u))) { if (u.compareTo(v) > 0) continue; // avoid duplicates @@ -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()) { @@ -475,11 +475,11 @@ static int countComponents(Graph graph) { } /** - * Attempt planar embedding via edge-addition for each biconnected component. + * Attempt planar embedding via Edge-addition for each biconnected component. * 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); @@ -517,7 +517,7 @@ private static boolean attemptPlanarEmbedding( /** * Check if a biconnected component contains a K5 or K3,3 minor. - * Uses edge contraction with a strategy that contracts low-degree vertices + * Uses Edge contraction with a strategy that contracts low-degree vertices * first, checking at each step for complete/bipartite minors. */ private static boolean containsK5OrK33Minor(Map> adj, @@ -655,7 +655,7 @@ private static boolean tryContractionStrategy(Map> adj, return false; } - /** Contract edge (u,v) by merging v into u. */ + /** Contract Edge (u,v) by merging v into u. */ private static void contractEdge(Map> g, String remove, String keep) { Set removeNbrs = g.get(remove); @@ -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..be5935d 100644 --- a/Gvisual/src/gvisual/RichClubAnalyzer.java +++ b/Gvisual/src/gvisual/RichClubAnalyzer.java @@ -22,7 +22,7 @@ *
      • Rich-club coefficient phi(k) for all degree thresholds
      • *
      • Normalized coefficient rho(k) = phi(k) / phi_rand(k) via randomized rewiring
      • *
      • Rich-club member identification at any threshold
      • - *
      • Rich-club density and internal edge fraction
      • + *
      • Rich-club density and internal Edge fraction
      • *
      • Degree assortativity (Pearson correlation of endpoint degrees)
      • *
      • Classification: rich-club, anti-rich-club, or neutral
      • *
      • CSV, JSON, and text report export
      • @@ -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"); @@ -183,7 +183,7 @@ public double internalEdgeFraction(int k) { } /** - * Computes degree assortativity (Pearson correlation of degrees at edge endpoints). + * Computes degree assortativity (Pearson correlation of degrees at Edge endpoints). * Positive values indicate rich-club tendency (hubs connect to hubs). * Negative values indicate disassortative mixing (hubs connect to periphery). * @@ -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 265d0a2..ee3e82d 100644 --- a/Gvisual/src/gvisual/ShortestPathFinder.java +++ b/Gvisual/src/gvisual/ShortestPathFinder.java @@ -5,7 +5,7 @@ /** * Finds shortest paths in a JUNG graph using BFS (unweighted) - * and Dijkstra-like traversal (weighted by edge weight). + * and Dijkstra-like traversal (weighted by Edge weight). * *

        Provides both hop-count-optimal and weight-optimal paths * between any two nodes in the network. Useful for analyzing @@ -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,17 +36,17 @@ public ShortestPathFinder(Graph graph) { */ public static class PathResult { private final List vertices; - private final List edges; + private final List edges; private final double totalWeight; /** * @param vertices ordered list of vertex IDs from source to target * @param edges ordered list of edges along the path - * @param totalWeight sum of edge weights 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; } @@ -65,7 +65,7 @@ public int getHopCount() { return edges.size(); } - /** Sum of edge weights along the path. */ + /** Sum of Edge weights along the path. */ public double getTotalWeight() { return totalWeight; } @@ -102,13 +102,13 @@ public PathResult findShortestByHops(String source, String target) { if (source.equals(target)) { return new PathResult( Collections.singletonList(source), - Collections.emptyList(), + Collections.emptyList(), 0.0); } // 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); @@ -135,7 +135,7 @@ public PathResult findShortestByHops(String source, String target) { } /** - * Finds the shortest path by total edge weight (Dijkstra) between source and target. + * Finds the shortest path by total Edge weight (Dijkstra) between source and target. * *

        Uses a typed {@link DijkstraEntry} in the priority queue for clean * vertex lookups without index indirection or double-to-int casting.

        @@ -152,7 +152,7 @@ public PathResult findShortestByWeight(String source, String target) { if (source.equals(target)) { return new PathResult( Collections.singletonList(source), - Collections.emptyList(), + Collections.emptyList(), 0.0); } @@ -162,7 +162,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(); @@ -184,14 +184,14 @@ 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; double edgeWeight = e.getWeight(); if (edgeWeight < 0) { throw new IllegalArgumentException( - "Dijkstra does not support negative edge weights. " + + "Dijkstra does not support negative Edge weights. " + "Edge between '" + current + "' and '" + neighbor + "' has weight " + edgeWeight); } @@ -231,7 +231,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); @@ -265,7 +265,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; @@ -313,13 +313,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); } @@ -332,16 +332,16 @@ 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; while (current != null) { vertices.add(current); - edge e = predecessorEdge.get(current); + Edge e = predecessorEdge.get(current); if (e != null) { edges.add(e); double w = e.getWeight(); diff --git a/Gvisual/src/gvisual/SignedGraphAnalyzer.java b/Gvisual/src/gvisual/SignedGraphAnalyzer.java index 2fd1509..21e9435 100644 --- a/Gvisual/src/gvisual/SignedGraphAnalyzer.java +++ b/Gvisual/src/gvisual/SignedGraphAnalyzer.java @@ -13,7 +13,7 @@ * *

        Features

        *
          - *
        • Sign assignment: Uses edge weight sign (positive/negative) or label (+/-)
        • + *
        • Sign assignment: Uses Edge weight sign (positive/negative) or label (+/-)
        • *
        • Triangle census: Counts balanced (+++, +−−) and unbalanced (++-,−−−) triangles
        • *
        • Structural balance check: Tests if graph is perfectly balanced (Harary's theorem)
        • *
        • Weak balance check: Davis's generalization allowing k > 2 coalitions
        • @@ -22,7 +22,7 @@ *
        • Balance degree: Fraction of balanced triangles (0.0 to 1.0)
        • *
        • Edge sign statistics: Counts and ratios of positive/negative edges
        • *
        • Vertex polarization: Per-vertex ratio of negative to total edges
        • - *
        • Sign prediction: Predict missing edge sign based on mutual neighbors
        • + *
        • Sign prediction: Predict missing Edge sign based on mutual neighbors
        • *
        * *

        Theory

        @@ -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"); } @@ -56,24 +56,24 @@ public SignedGraphAnalyzer(Graph graph) { } /** - * Determines if an edge is negative. + * Determines if an Edge is negative. * - * @param e the edge - * @return true if edge is negative (weight < 0 or label is "-"/"negative") + * @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")); } /** - * Determines if an edge is positive. + * Determines if an Edge is positive. * - * @param e the edge - * @return true if edge is positive + * @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; @@ -297,7 +297,7 @@ public boolean isStronglyBalanced() { String u = queue.poll(); int cu = color.get(u); for (String v : adj.getOrDefault(u, Collections.emptyList())) { - edge e = edgeMap.get(u).get(v); + Edge e = edgeMap.get(u).get(v); int expectedColor = isNegative(e) ? (1 - cu) : cu; if (color.containsKey(v)) { if (color.get(v) != expectedColor) return false; @@ -313,7 +313,7 @@ public boolean isStronglyBalanced() { /** * Tests if the graph is weakly balanced (Davis's criterion). - * Weakly balanced iff no cycle has exactly one negative edge. + * Weakly balanced iff no cycle has exactly one negative Edge. * Equivalent to: no ++-triangle exists. * *

        For efficiency, checks triangle census for ppn = 0 (necessary condition) @@ -325,16 +325,16 @@ public boolean isWeaklyBalanced() { if (graph.getVertexCount() == 0) return true; // Weak balance: vertices can be partitioned into k≥2 groups, // positive within, negative between. - // Check: the positive-edge subgraph's connected components must have + // Check: the positive-Edge subgraph's connected components must have // only negative edges between them. Map component = new HashMap<>(); Map> posAdj = new HashMap<>(); 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(); @@ -382,7 +382,7 @@ public boolean isWeaklyBalanced() { /** * Finds coalitions (groups) in a balanced or near-balanced graph. * Uses the 2-coloring from strong balance check if balanced, - * otherwise uses positive-edge connected components. + * otherwise uses positive-Edge connected components. * * @return list of coalitions (each is a set of vertex names) */ @@ -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; @@ -411,7 +411,7 @@ private List> findStrongCoalitions() { int cu = color.get(u); for (String v : adj.getOrDefault(u, Collections.emptyList())) { if (color.containsKey(v)) continue; - edge e = edgeMap.get(u).get(v); + Edge e = edgeMap.get(u).get(v); color.put(v, isNegative(e) ? (1 - cu) : cu); queue.add(v); } @@ -426,13 +426,13 @@ private List> findStrongCoalitions() { } private List> findWeakCoalitions() { - // Use positive-edge connected components + // Use positive-Edge connected components Map component = new HashMap<>(); Map> posAdj = new HashMap<>(); 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(); @@ -513,7 +513,7 @@ private int exactFrustration(List vertices) { int iv = idx.get(v); boolean sameGroup = getBit(mask, iu) == getBit(mask, iv); boolean pos = isPositive(e); - // Frustrated if: positive edge between groups, or negative edge within group + // Frustrated if: positive Edge between groups, or negative Edge within group if ((pos && !sameGroup) || (!pos && sameGroup)) { frustration++; } @@ -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; @@ -545,7 +545,7 @@ private int greedyFrustration(List vertices) { int cu = color.get(u); for (String v : adj.getOrDefault(u, Collections.emptyList())) { if (color.containsKey(v)) continue; - edge e = edgeMap.get(u).get(v); + Edge e = edgeMap.get(u).get(v); color.put(v, isNegative(e) ? (1 - cu) : cu); queue.add(v); } @@ -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; @@ -608,7 +608,7 @@ private Map computePartition() { int cu = color.get(u); for (String v : adj.getOrDefault(u, Collections.emptyList())) { if (color.containsKey(v)) continue; - edge e = edgeMap.get(u).get(v); + Edge e = edgeMap.get(u).get(v); color.put(v, isNegative(e) ? (1 - cu) : cu); queue.add(v); } @@ -620,11 +620,11 @@ private Map computePartition() { // ---- Sign Prediction ---- /** - * Predicts the sign of a potential edge between two vertices based on + * Predicts the sign of a potential Edge between two vertices based on * mutual neighbor signs (triadic closure principle). * *

        For each mutual neighbor w: if sign(u,w) * sign(w,v) is positive, - * it votes for a positive edge; otherwise negative. Majority wins.

        + * it votes for a positive Edge; otherwise negative. Majority wins.

        * * @param u first vertex * @param v second vertex @@ -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..ef05dae 100644 --- a/Gvisual/src/gvisual/SteinerTreeAnalyzer.java +++ b/Gvisual/src/gvisual/SteinerTreeAnalyzer.java @@ -30,7 +30,7 @@ *
      • Steiner ratio: cost(Steiner tree) / cost(MST of terminals)
      • *
      • Steiner points: non-terminal vertices used in the optimal tree
      • *
      • Terminal reachability: which terminals can be connected
      • - *
      • Bottleneck edge: heaviest edge in the Steiner tree
      • + *
      • Bottleneck Edge: heaviest Edge in the Steiner tree
      • *
      • Savings analysis: cost reduction vs direct MST on terminals
      • *
      • Vertex importance: how much removing a Steiner point increases cost
      • *
      @@ -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(); @@ -523,7 +523,7 @@ private void reconstructDP(double[][] dp, int[][][] parent, double[][] dist, if (splitMask < 0) return; if (splitMask == S) { - // Came from edge relaxation: dp[S][v] = dp[S][splitVert] + dist[splitVert][v] + // Came from Edge relaxation: dp[S][v] = dp[S][splitVert] + dist[splitVert][v] // Add path from splitVert to v addShortestPath(next, splitVert, v, vertList, treeEdges, treeVertices); reconstructDP(dp, parent, dist, next, S, splitVert, vertList, idx, termList, treeEdges, treeVertices); @@ -582,7 +582,7 @@ public SteinerTreeResult solve(Set terminals) { // ── Analysis ────────────────────────────────────────────────── /** - * Finds the bottleneck (heaviest) edge in a Steiner tree. + * Finds the bottleneck (heaviest) Edge in a Steiner tree. */ public EdgeInfo bottleneckEdge(SteinerTreeResult result) { return result.edges.stream() @@ -737,7 +737,7 @@ private String sorted(Set set) { } private double getEdgeWeight(String u, String v) { - edge e = graph.findEdge(u, v); + Edge e = graph.findEdge(u, v); if (e == null) e = graph.findEdge(v, u); if (e == null) return 1.0; return e.getWeight() > 0 ? e.getWeight() : 1.0; diff --git a/Gvisual/src/gvisual/StronglyConnectedComponentsAnalyzer.java b/Gvisual/src/gvisual/StronglyConnectedComponentsAnalyzer.java index f34ab74..03376d4 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..c9122ba 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"); } @@ -180,7 +180,7 @@ public BrokerageReport(int vertexCount, int edgeCount, } /** - * An edge that bridges structural holes. + * An Edge that bridges structural holes. */ public static class BridgingEdge { private final String vertex1; @@ -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; @@ -555,7 +555,7 @@ Map computePairwiseConstraint(String vertex, Set neighbo } /** - * Bridge score: fraction of ego's edges where removing the edge + * Bridge score: fraction of ego's edges where removing the Edge * would increase the number of connected components in ego's * neighborhood subgraph. */ diff --git a/Gvisual/src/gvisual/SubgraphExtractor.java b/Gvisual/src/gvisual/SubgraphExtractor.java index ead84e4..c2f51ba 100644 --- a/Gvisual/src/gvisual/SubgraphExtractor.java +++ b/Gvisual/src/gvisual/SubgraphExtractor.java @@ -35,7 +35,7 @@ * .filterByMinWeight(3.0f) * .connectedOnly(true); * SubgraphExtractor.Result result = ext.extract(); - * Graph<String, edge> subgraph = result.getGraph(); + * Graph<String, Edge> subgraph = result.getGraph(); * * // 2-hop neighborhood of node "42" * SubgraphExtractor ext2 = new SubgraphExtractor(graph, allEdges) @@ -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<>(); @@ -67,12 +67,12 @@ public class SubgraphExtractor { private boolean connectedOnly = false; /** - * Creates a new SubgraphExtractor for the given graph and edge list. + * Creates a new SubgraphExtractor for the given graph and Edge list. * * @param graph the source JUNG graph - * @param allEdges the full edge list (used for filtering before graph insertion) + * @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; @@ -82,7 +82,7 @@ public SubgraphExtractor(Graph graph, List allEdges) { /** * Keep only edges of the specified type code(s). * - * @param typeCodes one or more edge type codes ("f", "c", "fs", "s", "sg") + * @param typeCodes one or more Edge type codes ("f", "c", "fs", "s", "sg") * @return this extractor for chaining */ public SubgraphExtractor filterByEdgeType(String... typeCodes) { @@ -95,7 +95,7 @@ public SubgraphExtractor filterByEdgeType(String... typeCodes) { /** * Keep only edges with weight >= minWeight. * - * @param minWeight minimum edge weight (inclusive) + * @param minWeight minimum Edge weight (inclusive) * @return this extractor for chaining */ public SubgraphExtractor filterByMinWeight(float minWeight) { @@ -106,7 +106,7 @@ public SubgraphExtractor filterByMinWeight(float minWeight) { /** * Keep only edges with weight <= maxWeight. * - * @param maxWeight maximum edge weight (inclusive) + * @param maxWeight maximum Edge weight (inclusive) * @return this extractor for chaining */ public SubgraphExtractor filterByMaxWeight(float maxWeight) { @@ -115,7 +115,7 @@ public SubgraphExtractor filterByMaxWeight(float maxWeight) { } /** - * After edge filtering, keep only nodes whose degree in the resulting + * After Edge filtering, keep only nodes whose degree in the resulting * subgraph falls within [minDegree, maxDegree]. * * @param minDegree minimum degree (inclusive), or null for no lower bound @@ -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()); @@ -299,15 +299,15 @@ private Set determineCandidateNodes() { /** * Holds the result of a subgraph extraction, including the extracted graph, - * the filtered edge list, and summary statistics. + * 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; } @@ -347,10 +347,10 @@ public double getEdgeRetention() { (double) graph.getEdgeCount() / originalEdgeCount; } - /** Returns a per-edge-type count breakdown. */ + /** 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; @@ -387,7 +387,7 @@ public String getSummary() { } /** - * Exports the subgraph as a CSV edge list. + * Exports the subgraph as a CSV Edge list. * * @param file output file * @throws IOException if writing fails @@ -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()), @@ -409,14 +409,14 @@ public void exportEdgeList(File file) throws IOException { } /** - * Returns the edge list as a CSV string. + * Returns the Edge list as a CSV string. * * @return CSV content */ 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..30a9e70 100644 --- a/Gvisual/src/gvisual/SubgraphPatternMatcher.java +++ b/Gvisual/src/gvisual/SubgraphPatternMatcher.java @@ -39,7 +39,7 @@ * VF2 algorithm. Candidates are ordered by descending degree in the pattern * graph (most constrained first) for faster pruning. For each pattern node, * the algorithm tries all compatible target nodes, checking degree - * consistency, neighbor consistency, and optional edge-type constraints.

      + * consistency, neighbor consistency, and optional Edge-type constraints.

      * *

      Complexity

      *

      Worst-case exponential in pattern size, but practical for patterns up @@ -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"); } @@ -351,7 +351,7 @@ public MatchResult findMatches() { Integer.compare(patternAdj.getOrDefault(b, Collections.emptySet()).size(), patternAdj.getOrDefault(a, Collections.emptySet()).size())); - // Compute degree map for target (with edge-type filter) + // Compute degree map for target (with Edge-type filter) Map targetDegree = new HashMap<>(); for (String v : target.getVertices()) { targetDegree.put(v, targetAdj.getOrDefault(v, Collections.emptySet()).size()); @@ -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,30 +545,30 @@ 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; } /** - * Create a diamond pattern (K4 minus one edge: 4 nodes, 5 edges). - * Shape: two triangles sharing an edge. + * 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..bae1261 100644 --- a/Gvisual/src/gvisual/SvgExporter.java +++ b/Gvisual/src/gvisual/SvgExporter.java @@ -22,7 +22,7 @@ *

    • Edge weight → stroke width scaling
    • *
    • Node degree → radius scaling
    • *
    • Node labels with automatic contrast (white on dark fills)
    • - *
    • Optional legend for edge types
    • + *
    • Optional legend for Edge types
    • *
    • Dark or light theme support
    • *
    • Configurable canvas dimensions and margins
    • *
    • Hover tooltips via SVG <title> elements
    • @@ -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"); } @@ -107,7 +107,7 @@ public SvgExporter(Graph graph) { /** Use dark background (default: true). */ public void setDarkTheme(boolean dark) { this.darkTheme = dark; } - /** Show edge type legend (default: true). */ + /** Show Edge type legend (default: true). */ public void setShowLegend(boolean show) { this.showLegend = show; } /** Show node labels (default: true). */ @@ -116,7 +116,7 @@ public SvgExporter(Graph graph) { /** Scale node radius by degree (default: true). */ public void setScaleNodesByDegree(boolean scale) { this.scaleNodesByDegree = scale; } - /** Scale edge stroke by weight (default: true). */ + /** Scale Edge stroke by weight (default: true). */ public void setScaleEdgesByWeight(boolean scale) { this.scaleEdgesByWeight = scale; } /** Color edges by type (default: true). */ @@ -127,7 +127,7 @@ public void setLayoutIterations(int iterations) { this.layoutIterations = Math.max(10, iterations); } - /** Override color for a specific edge type code. */ + /** Override color for a specific Edge type code. */ public void setTypeColor(String type, String hexColor) { customColors.put(type, hexColor); } @@ -166,16 +166,16 @@ 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()); } if (minWeight == Float.MAX_VALUE) { minWeight = 0; maxWeight = 1; } if (maxWeight <= minWeight) maxWeight = minWeight + 1; - // Collect used edge types + // 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()); } @@ -209,7 +209,7 @@ public String exportToString() { sb.append("; stroke: ").append(nodeStroke).append("; stroke-width: 1.5; }\n"); sb.append(" .node-label { fill: ").append(textColor); sb.append("; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; text-anchor: middle; dominant-baseline: central; }\n"); - sb.append(" .edge-line { stroke-linecap: round; }\n"); + sb.append(" .Edge-line { stroke-linecap: round; }\n"); sb.append(" .title-text { fill: ").append(textColor); sb.append("; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; }\n"); sb.append(" .legend-text { fill: ").append(textColor); @@ -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; @@ -256,7 +256,7 @@ public String exportToString() { strokeWidth = 0.5 + ratio * 3.5; } - sb.append(" 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..2d5e0bd 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:

      @@ -18,14 +18,14 @@ *
    * *

    All generated subgraphs are independent copies (new vertices and edges - * referencing the same edge objects) so modifications won't affect the + * referencing the same Edge objects) so modifications won't affect the * original graph.

    * * @author zalenix */ 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,21 +45,21 @@ public TemporalGraph(Graph graph) { * * @return the full graph */ - public Graph getFullGraph() { + public Graph getFullGraph() { return fullGraph; } /** * Returns a snapshot of the graph at a specific point in time. - * Only edges that are active at the given time (per {@link edge#isActiveAt(long)}) + * Only edges that are active at the given time (per {@link Edge#isActiveAt(long)}) * are included. Vertices with no active edges are excluded. * * @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; @@ -153,10 +153,10 @@ public List>> generateWindows(int windowCoun } /** - * Adds an edge and its endpoints to a graph, skipping if the edge + * 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..6b90988 100644 --- a/Gvisual/src/gvisual/ToolbarBuilder.java +++ b/Gvisual/src/gvisual/ToolbarBuilder.java @@ -33,19 +33,19 @@ public final class ToolbarBuilder { private static final Logger LOGGER = Logger.getLogger(ToolbarBuilder.class.getName()); - /** Callback interface for the host to supply live graph + edge data. */ + /** 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 */ } @@ -147,7 +147,7 @@ private static void addSnapshotButton(JPanel panel, GraphContext ctx) { private static void addEdgelistExportButton(JPanel panel) { JButton btn = new JButton( - "
    Export edgelist
    Export the graph
    edge list in
    CSV format.
    "); + "
    Export edgelist
    Export the graph
    Edge list in
    CSV format.
    "); btn.setPreferredSize(new Dimension(140, 100)); btn.addActionListener(e -> { JFileChooser fc; @@ -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..5b74e26 100644 --- a/Gvisual/src/gvisual/TopologicalSortAnalyzer.java +++ b/Gvisual/src/gvisual/TopologicalSortAnalyzer.java @@ -9,7 +9,7 @@ * detection, dependency analysis, and critical path computation. * *

    Topological sort produces a linear ordering of vertices such - * that for every directed edge (u → v), vertex u comes before v. This + * that for every directed Edge (u → v), vertex u comes before v. This * is only possible on Directed Acyclic Graphs (DAGs).

    * *

    Use cases:

    @@ -25,13 +25,13 @@ * participating in cycles and reports the back edges that cause them.

    * *

    Algorithms: Kahn's algorithm (BFS-based) for the primary sort, - * DFS-based traversal for cycle detection and back-edge reporting.

    + * DFS-based traversal for cycle detection and back-Edge reporting.

    * * @author zalenix */ 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(); } @@ -196,7 +196,7 @@ private GraphUtils.DirectedAdj buildDirectedAdj() { /** * Perform a full topological sort analysis. * - *

    The graph's edges are interpreted as directed: for each edge, + *

    The graph's edges are interpreted as directed: for each Edge, * vertex1 → vertex2 represents a dependency (vertex2 depends on * vertex1, or equivalently vertex1 must come before vertex2).

    * @@ -519,9 +519,9 @@ private void dfsCycleDetect(String v, Map> successors, for (String w : succs) { if (color.get(w) == 1) { - // Back edge found → extract cycle + // 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; @@ -534,7 +534,7 @@ private void dfsCycleDetect(String v, Map> successors, for (int i = 0; i < cycleVertices.size(); i++) { String from = cycleVertices.get(i); String to = cycleVertices.get((i + 1) % cycleVertices.size()); - edge e = findEdge(from, to); + Edge e = findEdge(from, to); if (e != null) cycleEdges.add(e); } @@ -566,10 +566,10 @@ private boolean isDuplicateCycle(List existing, List newCycle } /** - * Find an edge from vertex1 to vertex2 in the graph. + * Find an Edge from vertex1 to vertex2 in the graph. */ - private edge findEdge(String from, String to) { - for (edge e : graph.getEdges()) { + private Edge findEdge(String from, String to) { + 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..876fc7e 100644 --- a/Gvisual/src/gvisual/TournamentAnalyzer.java +++ b/Gvisual/src/gvisual/TournamentAnalyzer.java @@ -8,7 +8,7 @@ * Tournament graph analyzer for directed complete graphs. * *

    A tournament is a directed graph obtained by assigning a direction - * to every edge in a complete graph. Equivalently, for every pair of distinct + * to every Edge in a complete graph. Equivalently, for every pair of distinct * vertices u and v, exactly one of (u→v) or (v→u) exists. Tournaments model * round-robin competitions, paired comparisons, and social choice.

    * @@ -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"); } @@ -61,7 +61,7 @@ public TournamentAnalyzer(Graph graph) { this.vertices = new ArrayList(graph.getVertices()); Collections.sort(this.vertices); // Delegate directed adjacency construction to GraphUtils to avoid - // duplicating the vertex1→vertex2 edge-walking logic. + // duplicating the vertex1→vertex2 Edge-walking logic. this.beats = GraphUtils.buildDirectedAdjacencyMap(graph).successors; } @@ -116,9 +116,9 @@ public List validate() { boolean uv = beats.get(u).contains(v); boolean vu = beats.get(v).contains(u); if (!uv && !vu) { - errors.add("Missing edge between " + u + " and " + v); + errors.add("Missing Edge between " + u + " and " + v); } else if (uv && vu) { - errors.add("Duplicate edge between " + u + " and " + v); + errors.add("Duplicate Edge between " + u + " and " + v); } } } @@ -626,7 +626,7 @@ private void dfsReverse(String v, Set visited, Set component, // ── Upset Detection ───────────────────────────────────────── /** - * Represents an upset: an edge from a lower-ranked to a higher-ranked vertex + * Represents an upset: an Edge from a lower-ranked to a higher-ranked vertex * (based on Copeland ranking). */ public static class Upset { diff --git a/Gvisual/src/gvisual/TreeAnalyzer.java b/Gvisual/src/gvisual/TreeAnalyzer.java index e97f579..dd15b07 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"); } @@ -551,7 +551,7 @@ public List encodePrufer() { } /** - * Decode a Prüfer sequence back into a tree (as edge list). + * Decode a Prüfer sequence back into a tree (as Edge list). * * @param sequence the Prüfer sequence * @param vertices the full set of vertex labels @@ -593,7 +593,7 @@ public static List decodePrufer(List sequence, List ve } } - // Last edge connects the two remaining vertices + // Last Edge connects the two remaining vertices List remaining = new ArrayList<>(); for (String v : sortedVertices) { if (!used.contains(v)) { diff --git a/Gvisual/src/gvisual/TreewidthAnalyzer.java b/Gvisual/src/gvisual/TreewidthAnalyzer.java index 0335c4f..5ce9d5a 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; } @@ -301,7 +301,7 @@ public int computeDegeneracy() { /** * Computes MMD (minimum maximum degree) lower bound. - * Iteratively contracts the edge with minimum degree endpoint. + * Iteratively contracts the Edge with minimum degree endpoint. */ public int computeMMDLowerBound() { if (graph.getVertexCount() == 0) return 0; @@ -670,7 +670,7 @@ private int adjustBag(List niceBags, int childIdx, Set targetVertic /** * Validates a tree decomposition. - * Checks: (1) every vertex in some bag, (2) every edge covered, + * Checks: (1) every vertex in some bag, (2) every Edge covered, * (3) bags containing each vertex form a connected subtree. */ public boolean validateDecomposition(TreeDecomposition td) { @@ -685,8 +685,8 @@ public boolean validateDecomposition(TreeDecomposition td) { if (!coveredVertices.contains(v)) return false; } - // Check every edge is covered by some bag - for (edge e : graph.getEdges()) { + // Check every Edge is covered by some bag + 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..069d0a2 100644 --- a/Gvisual/src/gvisual/VertexConnectivityAnalyzer.java +++ b/Gvisual/src/gvisual/VertexConnectivityAnalyzer.java @@ -14,18 +14,18 @@ *
  • Edge connectivity (λ) — minimum number of edges whose * removal disconnects the graph
  • *
  • Minimum vertex cut — an actual set of vertices achieving κ
  • - *
  • Minimum edge cut — an actual set of edges achieving λ
  • + *
  • Minimum Edge cut — an actual set of edges achieving λ
  • *
  • Pairwise connectivity — κ(s,t) and λ(s,t) between two vertices
  • *
  • k-connectivity test — whether the graph is k-vertex-connected
  • *
  • Whitney's inequality — verifies κ ≤ λ ≤ δ
  • *
  • All minimum vertex cuts — enumerates all minimum-size separating sets
  • *
  • Vertex criticality — connectivity drop per vertex removal
  • - *
  • Vertex/edge-disjoint paths — Menger's theorem verification
  • + *
  • Vertex/Edge-disjoint paths — Menger's theorem verification
  • * * *

    Uses Edmonds-Karp (BFS-based Ford-Fulkerson) max-flow on a transformed * network where each vertex v is split into v_in → v_out with capacity 1, - * and each original edge becomes two unit-capacity arcs.

    + * and each original Edge becomes two unit-capacity arcs.

    * *

    Usage:

    *
    @@ -33,7 +33,7 @@
      * int kappa = analyzer.vertexConnectivity();
      * int lambda = analyzer.edgeConnectivity();
      * Set<String> minCut = analyzer.minimumVertexCut();
    - * Set<edge> minEdgeCut = analyzer.minimumEdgeCut();
    + * Set<Edge> minEdgeCut = analyzer.minimumEdgeCut();
      * boolean is3connected = analyzer.isKVertexConnected(3);
      * PairwiseResult pr = analyzer.pairwiseConnectivity("A", "B");
      * String report = analyzer.generateReport();
    @@ -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; }
         }
    @@ -185,7 +185,7 @@ public int vertexConnectivity() {
         }
     
         /**
    -     * Compute edge connectivity λ(G).
    +     * Compute Edge connectivity λ(G).
          * λ = min over all s,t of λ(s,t).
          * Optimization: fix s, compute λ(s,t) for all t.
          */
    @@ -244,9 +244,9 @@ public Set minimumVertexCut() {
         }
     
         /**
    -     * Find a minimum edge cut set.
    +     * Find a minimum Edge cut set.
          */
    -    public Set minimumEdgeCut() {
    +    public Set minimumEdgeCut() {
             int n = graph.getVertexCount();
             if (n <= 1 || !isConnected()) return Collections.emptySet();
     
    @@ -277,7 +277,7 @@ public boolean isKVertexConnected(int k) {
         }
     
         /**
    -     * Test if graph is k-edge-connected.
    +     * Test if graph is k-Edge-connected.
          */
         public boolean isKEdgeConnected(int k) {
             if (k <= 0) return true;
    @@ -285,8 +285,8 @@ public boolean isKEdgeConnected(int k) {
         }
     
         /**
    -     * Pairwise vertex and edge connectivity between s and t.
    -     * Includes vertex-disjoint and edge-disjoint paths (Menger's theorem).
    +     * Pairwise vertex and Edge connectivity between s and t.
    +     * Includes vertex-disjoint and Edge-disjoint paths (Menger's theorem).
          */
         public PairwiseResult pairwiseConnectivity(String s, String t) {
             if (s == null || t == null) throw new IllegalArgumentException("Vertices must not be null");
    @@ -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) {
    +            sb.append("Minimum Edge cut:\n");
    +            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();
    @@ -772,14 +772,14 @@ public List> findVertexDisjointPaths(String s, String t) {
         }
     
         /**
    -     * Find edge-disjoint paths between s and t.
    +     * Find Edge-disjoint paths between s and t.
          */
         public List> findEdgeDisjointPaths(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();
    @@ -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..c75fa9e 100644
    --- a/Gvisual/src/gvisual/VertexCoverAnalyzer.java
    +++ b/Gvisual/src/gvisual/VertexCoverAnalyzer.java
    @@ -7,13 +7,13 @@
      * Vertex Cover Analyzer — finds and analyses vertex covers in a graph.
      *
      * 
    - * A vertex cover C is a subset of vertices such that every edge + * A vertex cover C is a subset of vertices such that every Edge * in E has at least one endpoint in C. *
    * *

    Features

    *
      - *
    • 2-approximation vertex cover — edge-matching heuristic + *
    • 2-approximation vertex cover — Edge-matching heuristic * guaranteed to produce a cover at most 2× optimal. O(V + E).
    • *
    • Greedy vertex cover — degree-based greedy that iteratively * picks the vertex covering the most uncovered edges. O(V·E).
    • @@ -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"); } @@ -62,7 +62,7 @@ public VertexCoverAnalyzer(Graph graph) { /** * Finds a vertex cover using the classic 2-approximation algorithm. - * Repeatedly picks an arbitrary uncovered edge and adds both endpoints. + * Repeatedly picks an arbitrary uncovered Edge and adds both endpoints. * Guaranteed to be at most 2× the optimal size. * * @return an unmodifiable set of vertex IDs forming a vertex cover @@ -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); @@ -224,14 +224,14 @@ private Set findCoverRecursive(List vertices, List edges, * Checks whether a given set of vertices is a valid vertex cover. * * @param cover the candidate vertex cover - * @return true if every edge has at least one endpoint in cover + * @return true if every Edge has at least one endpoint in cover * @throws IllegalArgumentException if cover is null */ 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)) { @@ -422,9 +422,9 @@ public double coverWeight(Set cover, Map weights) { public int lpRelaxationBound() { if (graph.getEdgeCount() == 0) return 0; // In the LP relaxation of vertex cover, the optimal fractional - // solution assigns 0.5 to every vertex incident to any edge. + // 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..ad2ae10 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..2cf37d8 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"); @@ -182,8 +182,8 @@ public void testFundamentalBasisTree() { @Test public void testFundamentalBasisSingleCycle() { - // Triangle: 1 non-tree edge → 1 fundamental cycle - Graph g = new UndirectedSparseGraph<>(); + // Triangle: 1 non-tree Edge → 1 fundamental cycle + 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/GraphComplementAnalyzerTest.java b/Gvisual/src/test/gvisual/GraphComplementAnalyzerTest.java index 5b106dc..10da756 100644 --- a/Gvisual/src/test/gvisual/GraphComplementAnalyzerTest.java +++ b/Gvisual/src/test/gvisual/GraphComplementAnalyzerTest.java @@ -12,11 +12,11 @@ */ public class GraphComplementAnalyzerTest { - private Graph makeTriangle() { - UndirectedSparseGraph g = new UndirectedSparseGraph<>(); + private Graph makeTriangle() { + UndirectedSparseGraph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - edge e1 = new edge("A", "B", "e1"); - edge e2 = new edge("B", "C", "e2"); + Edge e1 = new Edge("A", "B", "e1"); + Edge e2 = new Edge("B", "C", "e2"); g.addEdge(e1, "A", "B"); g.addEdge(e2, "B", "C"); return g; @@ -24,8 +24,8 @@ private Graph makeTriangle() { @Test public void complementEdgeCountPlusOriginalEqualsComplete() { - Graph g = makeTriangle(); - Graph comp = GraphComplementAnalyzer.buildComplement(g); + Graph g = makeTriangle(); + Graph comp = GraphComplementAnalyzer.buildComplement(g); int n = g.getVertexCount(); int maxEdges = n * (n - 1) / 2; assertEquals(maxEdges, g.getEdgeCount() + comp.getEdgeCount()); @@ -33,20 +33,20 @@ public void complementEdgeCountPlusOriginalEqualsComplete() { @Test public void complementOfCompleteGraphIsEmpty() { - UndirectedSparseGraph g = new UndirectedSparseGraph<>(); + UndirectedSparseGraph g = new UndirectedSparseGraph<>(); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); - g.addEdge(new edge("A", "B", "1"), "A", "B"); - g.addEdge(new edge("B", "C", "2"), "B", "C"); - g.addEdge(new edge("A", "C", "3"), "A", "C"); + g.addEdge(new Edge("A", "B", "1"), "A", "B"); + g.addEdge(new Edge("B", "C", "2"), "B", "C"); + g.addEdge(new Edge("A", "C", "3"), "A", "C"); - Graph comp = GraphComplementAnalyzer.buildComplement(g); + Graph comp = GraphComplementAnalyzer.buildComplement(g); assertEquals(0, comp.getEdgeCount()); } @Test public void complementPreservesVertices() { - Graph g = makeTriangle(); - Graph comp = GraphComplementAnalyzer.buildComplement(g); + Graph g = makeTriangle(); + Graph comp = GraphComplementAnalyzer.buildComplement(g); assertEquals(g.getVertexCount(), comp.getVertexCount()); for (String v : g.getVertices()) { assertTrue(comp.containsVertex(v)); @@ -55,7 +55,7 @@ public void complementPreservesVertices() { @Test public void analyzeProducesReport() { - Graph g = makeTriangle(); + Graph g = makeTriangle(); String report = GraphComplementAnalyzer.analyze(g); assertTrue(report.contains("GRAPH COMPLEMENT ANALYSIS")); assertTrue(report.contains("Density")); @@ -63,9 +63,9 @@ public void analyzeProducesReport() { @Test public void getComplementEdgeListWorks() { - Graph g = makeTriangle(); + Graph g = makeTriangle(); List edges = GraphComplementAnalyzer.getComplementEdgeList(g); - // Triangle with 2 edges, 3 vertices → max 3 edges → complement has 1 edge + // Triangle with 2 edges, 3 vertices → max 3 edges → complement has 1 Edge assertEquals(1, edges.size()); } } diff --git a/Gvisual/src/test/gvisual/GraphCompressorTest.java b/Gvisual/src/test/gvisual/GraphCompressorTest.java index 4f23ed7..38762c9 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..be4cb34 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() { @@ -21,8 +21,8 @@ public void setUp() { graphB = new UndirectedSparseGraph<>(); } - private edge makeEdge(String v1, String v2, float weight) { - edge e = new edge("f", v1, v2); + private Edge makeEdge(String v1, String v2, float weight) { + Edge e = new Edge("f", v1, v2); e.setWeight(weight); return e; } @@ -75,7 +75,7 @@ public void testUnionConflictAverage() { assertEquals(1, result.getMergedEdgeCount()); assertEquals(1, result.getConflictsResolved()); - edge merged = result.getMergedGraph().getEdges().iterator().next(); + Edge merged = result.getMergedGraph().getEdges().iterator().next(); assertEquals(5.0f, merged.getWeight(), 0.001f); } @@ -90,7 +90,7 @@ public void testUnionConflictMax() { GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, GraphMerger.Strategy.UNION, GraphMerger.EdgeConflict.MAX); - edge merged = result.getMergedGraph().getEdges().iterator().next(); + Edge merged = result.getMergedGraph().getEdges().iterator().next(); assertEquals(7.0f, merged.getWeight(), 0.001f); } @@ -105,7 +105,7 @@ public void testUnionConflictSum() { GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, GraphMerger.Strategy.UNION, GraphMerger.EdgeConflict.SUM); - edge merged = result.getMergedGraph().getEdges().iterator().next(); + Edge merged = result.getMergedGraph().getEdges().iterator().next(); assertEquals(8.0f, merged.getWeight(), 0.001f); } @@ -152,7 +152,7 @@ public void testSymmetricDifference() { graphA.addEdge(makeEdge("B", "C", 2.0f), "B", "C"); graphB.addVertex("B"); graphB.addVertex("C"); graphB.addVertex("D"); - graphB.addEdge(makeEdge("B", "C", 3.0f), "B", "C"); // Same edge as A + graphB.addEdge(makeEdge("B", "C", 3.0f), "B", "C"); // Same Edge as A graphB.addEdge(makeEdge("C", "D", 4.0f), "C", "D"); GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, diff --git a/Gvisual/src/test/gvisual/GraphProductCalculatorTest.java b/Gvisual/src/test/gvisual/GraphProductCalculatorTest.java index 88edcc0..2d8990b 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 } @@ -92,7 +92,7 @@ public void testLexicographicVertexCount() { assertEquals(6, calc.lexicographicProduct().getVertexCount()); } - // --- Cartesian product edge counts --- + // --- Cartesian product Edge counts --- @Test public void testCartesianK3xP2Edges() { @@ -116,7 +116,7 @@ public void testCartesianWithSingleVertex() { assertEquals(3, calc.cartesianProduct().getVertexCount()); } - // --- Tensor product edge counts --- + // --- Tensor product Edge counts --- @Test public void testTensorK3xP2Edges() { @@ -140,7 +140,7 @@ public void testTensorWithEmptyGraph() { assertEquals(9, calc.tensorProduct().getVertexCount()); } - // --- Strong product edge counts --- + // --- Strong product Edge counts --- @Test public void testStrongK3xP2Edges() { @@ -156,7 +156,7 @@ public void testStrongK2xK2Edges() { assertEquals(6, calc.strongProduct().getEdgeCount()); } - // --- Lexicographic product edge counts --- + // --- Lexicographic product Edge counts --- @Test public void testLexicographicK3xP2Edges() { @@ -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..9a53f40 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..7c28c74 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); + private Edge addEdge(String v1, String v2, String type) { + Edge e = new Edge(type, v1, v2); e.setLabel(v1 + "-" + v2); graph.addEdge(e, v1, v2); return e; @@ -66,8 +66,8 @@ public void testTwoVerticesOneBridge() { ArticulationPointAnalyzer.AnalysisResult result = analyzer.analyze(); assertEquals(2, result.getTotalVertices()); assertEquals(1, result.getTotalEdges()); - // Two vertices connected by one edge: no articulation points (removing either - // just leaves one isolated vertex), but the edge is a bridge + // Two vertices connected by one Edge: no articulation points (removing either + // just leaves one isolated vertex), but the Edge is a bridge assertEquals(1, result.getBridgeCount()); assertTrue(result.hasCriticalElements()); } diff --git a/Gvisual/test/gvisual/BipartiteAnalyzerTest.java b/Gvisual/test/gvisual/BipartiteAnalyzerTest.java index a2c3136..070cd56 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); + private Edge addEdge(String v1, String 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); @@ -69,7 +69,7 @@ public void singleVertexIsBipartite() { } // ═══════════════════════════════════════ - // Single edge (trivial bipartite) + // Single Edge (trivial bipartite) // ═══════════════════════════════════════ @Test @@ -392,8 +392,8 @@ public void vertexCoverCoversAllEdges() { BipartiteAnalyzer ba = new BipartiteAnalyzer(graph).compute(); 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()) { + // Every Edge must have at least one endpoint in the cover + 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, @@ -500,7 +500,7 @@ public void summaryNonBipartite() { } // ═══════════════════════════════════════ - // Matching edge equals/hashCode + // Matching Edge equals/hashCode // ═══════════════════════════════════════ @Test diff --git a/Gvisual/test/gvisual/ChordalGraphAnalyzerTest.java b/Gvisual/test/gvisual/ChordalGraphAnalyzerTest.java index 9b20a57..a6ee9bf 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; @@ -71,7 +71,7 @@ public void setUp() { addEdge(complete4, "B", "D"); addEdge(complete4, "C", "D"); - // Diamond: K4 minus B-D edge → A-B, A-C, A-D, B-C, C-D (chordal) + // Diamond: K4 minus B-D Edge → A-B, A-C, A-D, B-C, C-D (chordal) diamond = new UndirectedSparseGraph<>(); addEdge(diamond, "A", "B"); addEdge(diamond, "A", "C"); @@ -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())); } @@ -436,7 +436,7 @@ public void testFillInEdgesAreValid() { assertEquals(2, fe.length); assertTrue(vertices.contains(fe[0])); assertTrue(vertices.contains(fe[1])); - assertTrue("Fill edge endpoints must be ordered", fe[0].compareTo(fe[1]) < 0); + assertTrue("Fill Edge endpoints must be ordered", fe[0].compareTo(fe[1]) < 0); } } diff --git a/Gvisual/test/gvisual/CircularLayoutTest.java b/Gvisual/test/gvisual/CircularLayoutTest.java index ce07ab8..e1b3b42 100644 --- a/Gvisual/test/gvisual/CircularLayoutTest.java +++ b/Gvisual/test/gvisual/CircularLayoutTest.java @@ -10,13 +10,13 @@ /** * Tests for CircularLayout — verifies all ordering strategies, dual-ring mode, - * SVG export, edge crossing counts, and edge cases. + * SVG export, Edge crossing counts, and Edge cases. */ 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() { @@ -41,8 +41,8 @@ public void setUp() { empty = new UndirectedSparseGraph<>(); } - private edge makeEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + private Edge makeEdge(String v1, String 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..06c5be7 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); + private Edge addEdge(String v1, String 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); @@ -106,7 +106,7 @@ public void testSingleVertexCliqueSize1() { } // ═══════════════════════════════════════ - // 4. Single edge + // 4. Single Edge // ═══════════════════════════════════════ @Test @@ -321,7 +321,7 @@ public void testBowtieContainsExpectedCliques() { @Test public void testOverlappingCliquesMultiple() { - // Two K3 sharing an edge: A-B-C and A-B-D + // Two K3 sharing an Edge: A-B-C and A-B-D makeComplete("A", "B", "C"); addEdge("A", "D"); addEdge("B", "D"); @@ -421,7 +421,7 @@ public void testGetCliquesOfSizeZeroResult() { @Test public void testGetCliquesOfSizeMultiple() { - // Two K3 sharing edge A-B + // Two K3 sharing Edge A-B makeComplete("A", "B", "C"); addEdge("A", "D"); addEdge("B", "D"); @@ -521,7 +521,7 @@ public void testTopParticipantsEmptyGraph() { @Test public void testOverlapsFindsSharedVertices() { - // Two K3 sharing edge A-B: {A,B,C} and {A,B,D} + // Two K3 sharing Edge A-B: {A,B,C} and {A,B,D} makeComplete("A", "B", "C"); addEdge("A", "D"); addEdge("B", "D"); @@ -588,7 +588,7 @@ public void testCoverageFraction() { @Test public void testCliqueGraphBasic() { - // Two K3 sharing edge A-B → overlap=2 + // Two K3 sharing Edge A-B → overlap=2 makeComplete("A", "B", "C"); addEdge("A", "D"); addEdge("B", "D"); @@ -601,7 +601,7 @@ public void testCliqueGraphBasic() { @Test public void testCliqueGraphHighThreshold() { - // Two K3 sharing edge → overlap=2, threshold=3 → no connection + // Two K3 sharing Edge → overlap=2, threshold=3 → no connection makeComplete("A", "B", "C"); addEdge("A", "D"); addEdge("B", "D"); @@ -679,7 +679,7 @@ public void testFormatSummaryContainsKeyInfo() { } // ═══════════════════════════════════════ - // Additional edge cases & coverage + // Additional Edge cases & coverage // ═══════════════════════════════════════ @Test @@ -702,7 +702,7 @@ public void testIdempotentCompute() { @Test public void testCliquesSortedBySizeDescending() { - // K3 and a separate edge → cliques: {A,B,C} (size 3), {D,E} (size 2) + // K3 and a separate Edge → cliques: {A,B,C} (size 3), {D,E} (size 2) makeComplete("A", "B", "C"); addEdge("D", "E"); CliqueAnalyzer ca = new CliqueAnalyzer(graph).compute(); @@ -712,7 +712,7 @@ public void testCliquesSortedBySizeDescending() { @Test public void testAverageCliqueSize() { - // K3 + separate edge: avg = (3+2)/2 = 2.5 + // K3 + separate Edge: avg = (3+2)/2 = 2.5 makeComplete("A", "B", "C"); addEdge("D", "E"); CliqueAnalyzer ca = new CliqueAnalyzer(graph).compute(); diff --git a/Gvisual/test/gvisual/CommunityDetectorTest.java b/Gvisual/test/gvisual/CommunityDetectorTest.java index 63a6eda..8f64c6d 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"); @@ -355,13 +355,13 @@ public void testLargerGraph() { @Test public void testMultipleEdgeTypes() { - // Community with mixed edge types + // Community with mixed Edge types 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..2002c7a 100644 --- a/Gvisual/test/gvisual/CommunityEvolutionTrackerTest.java +++ b/Gvisual/test/gvisual/CommunityEvolutionTrackerTest.java @@ -18,20 +18,20 @@ public class CommunityEvolutionTrackerTest { // ── Helper Methods ───────────────────────────────────────────── - private edge timedEdge(String type, String v1, String v2, long timestamp) { - edge e = new edge(type, v1, v2); + private Edge timedEdge(String type, String v1, String v2, long timestamp) { + 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); + private Edge intervalEdge(String type, String v1, String v2, long start, long end) { + 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..922d6cb 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); @@ -85,7 +85,7 @@ public void testTriangleGraphMetrics() { assertTrue(csv.contains("Nodes: 3")); assertTrue(csv.contains("Edges: 3")); - // Each node has degree 2, friend edge count 2 + // Each node has degree 2, friend Edge count 2 // Clustering coefficient of a triangle node = 1.0 String[] lines = csv.split("\n"); // 2 comment + 1 header + 3 data = 6 lines @@ -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); @@ -166,7 +166,7 @@ public void testEdgeTypeCounts() { } assertNotNull(xLine); // X,2,1,1,0,0,0,... - assertTrue("X should have 1 friend and 1 fs edge", + assertTrue("X should have 1 friend and 1 fs Edge", xLine.startsWith("X,2,1,1,0,0,0,")); } @@ -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..7de04df 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,9 +104,9 @@ 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 + {"D", "E"} // separate tree Edge }); assertTrue(new CycleAnalyzer(g).hasCycles()); } @@ -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..12c510a 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); + private Edge addEdge(String v1, String 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); @@ -98,7 +98,7 @@ public void testSingleIsolatedVertex() { } // ═══════════════════════════════════════ - // Two vertices, one edge + // Two vertices, one Edge // ═══════════════════════════════════════ @Test @@ -646,7 +646,7 @@ public void testDegreesAreSorted() { } // ═══════════════════════════════════════ - // Coefficient of variation edge cases + // Coefficient of variation Edge cases // ═══════════════════════════════════════ @Test diff --git a/Gvisual/test/gvisual/DominatingSetAnalyzerTest.java b/Gvisual/test/gvisual/DominatingSetAnalyzerTest.java index ddaedd0..a5c32be 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); + private Edge addEdge(String v1, String 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..4e04216 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"); } @@ -107,7 +107,7 @@ public void testEdgeTypeColoring() { DotExporter exporter = new DotExporter(undirectedGraph); exporter.setColorByEdgeType(true); String dot = exporter.exportToString(); - // Should have legend subgraph with edge types + // Should have legend subgraph with Edge types assertTrue("Should contain legend", dot.contains("cluster_legend")); // Should contain the type colors assertTrue("Should contain Friend legend", dot.contains("Friend")); @@ -125,7 +125,7 @@ public void testNoEdgeTypeColoring() { public void testEdgeLabelInOutput() { DotExporter exporter = new DotExporter(undirectedGraph); String dot = exporter.exportToString(); - assertTrue("Should contain edge label", dot.contains("\"friendship\"")); + assertTrue("Should contain Edge label", dot.contains("\"friendship\"")); } @Test @@ -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..e8e29a3 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,25 +45,25 @@ 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"); TemporalGraph tg = new TemporalGraph(graph); EdgePersistenceAnalyzer epa = new EdgePersistenceAnalyzer(tg, 10); - Map result = epa.classify(); + Map result = epa.classify(); assertEquals(EdgePersistenceAnalyzer.PERSISTENT, result.get(e1)); } @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 @@ -72,18 +72,18 @@ public void testClassify_transientEdge() { TemporalGraph tg = new TemporalGraph(graph); EdgePersistenceAnalyzer epa = new EdgePersistenceAnalyzer(tg, 20); - Map result = epa.classify(); + Map result = epa.classify(); assertEquals(EdgePersistenceAnalyzer.TRANSIENT, result.get(e2)); } @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 @@ -92,10 +92,10 @@ public void testClassify_periodicEdge() { TemporalGraph tg = new TemporalGraph(graph); EdgePersistenceAnalyzer epa = new EdgePersistenceAnalyzer(tg, 10); - Map result = epa.classify(); + Map result = epa.classify(); // e2 should be periodic (present in ~50% of windows) String c2 = result.get(e2); - assertTrue("Half-range edge should be periodic", + assertTrue("Half-range Edge should be periodic", EdgePersistenceAnalyzer.PERIODIC.equals(c2) || EdgePersistenceAnalyzer.PERSISTENT.equals(c2)); } @@ -109,14 +109,14 @@ 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"); TemporalGraph tg = new TemporalGraph(graph); EdgePersistenceAnalyzer epa = new EdgePersistenceAnalyzer(tg, 1); - Map result = epa.classify(); + Map result = epa.classify(); // With 1 window, ratio is 1.0 => persistent assertEquals(EdgePersistenceAnalyzer.PERSISTENT, result.get(e1)); } @@ -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..831c8e6 100644 --- a/Gvisual/test/gvisual/EdgeTest.java +++ b/Gvisual/test/gvisual/EdgeTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.*; /** - * Unit tests for the {@link edge} class. + * Unit tests for the {@link Edge} class. * * Covers constructors, getters, weight/label properties, and * ensures default (no-arg) construction leaves fields null. @@ -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,22 +129,22 @@ 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()); } @Test public void testSelfLoop() { - // edge class doesn't prevent self-loops — verify it stores them - edge e = new edge("f", "X", "X"); + // Edge class doesn't prevent self-loops — verify it stores them + 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..c9669f1 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"); @@ -47,9 +47,9 @@ public void testTriangleIsEulerianCircuit() { @Test public void testSquareWithDiagonalsIsEulerianCircuit() { - // K4 minus one edge won't work; use a proper even-degree graph + // 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,9 +91,9 @@ 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", "B"); // multi-Edge simulated with different Edge objects addEdge(g, "A", "C"); addEdge(g, "A", "C"); addEdge(g, "A", "D"); @@ -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"); @@ -330,12 +330,12 @@ public void testReportForNonEulerian() { String report = analyzer.generateReport(); assertTrue(report.contains("NOT_EULERIAN")); assertTrue(report.contains("Chinese Postman")); - assertTrue(report.contains("Suggested edge additions")); + assertTrue(report.contains("Suggested Edge additions")); } @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..1a4aca5 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..66fa391 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) { + 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++; @@ -241,8 +241,8 @@ public void testEdgeWeightsInfluenceLayout() { double distAC = Math.sqrt(Math.pow(pA[0] - pC[0], 2) + Math.pow(pA[1] - pC[1], 2)); - // With weights, heavy edge A-B should pull tighter than weak A-C - assertTrue("Heavy edge should produce closer nodes: AB=" + + // With weights, heavy Edge A-B should pull tighter than weak A-C + assertTrue("Heavy Edge should produce closer nodes: AB=" + distAB + " AC=" + distAC, distAB < distAC); } @@ -292,8 +292,8 @@ public void testEdgeLengthUniformityOnTriangle() { ForceDirectedLayout layout = new ForceDirectedLayout(graph); layout.compute(); double cv = layout.edgeLengthUniformity(); - // Triangle should have fairly uniform edge lengths - assertTrue("Triangle edge lengths should be fairly uniform: " + cv, + // Triangle should have fairly uniform Edge lengths + assertTrue("Triangle Edge lengths should be fairly uniform: " + cv, cv < 0.5); } @@ -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..d37f821 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..d6410d0 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..a055a87 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); @@ -307,7 +307,7 @@ public void testExportImportRoundTrip() { manager.annotateNode("A").setColor("#FF0000"); manager.annotateNode("A").setAuthor("alice"); manager.annotateNode("A").setPriority(GraphAnnotationManager.Annotation.Priority.HIGH); - manager.annotateEdge("X", "Y").setNote("Test edge"); + manager.annotateEdge("X", "Y").setNote("Test Edge"); manager.annotateEdge("X", "Y").addTag("bridge"); String json = manager.exportToJson(); @@ -326,7 +326,7 @@ public void testExportImportRoundTrip() { GraphAnnotationManager.Annotation e = manager2.getEdgeAnnotation("X", "Y"); assertNotNull(e); - assertEquals("Test edge", e.getNote()); + assertEquals("Test Edge", e.getNote()); assertTrue(e.hasTag("bridge")); } diff --git a/Gvisual/test/gvisual/GraphAnomalyDetectorTest.java b/Gvisual/test/gvisual/GraphAnomalyDetectorTest.java index c546f1d..5ffe2ad 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); + /** 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); e.setWeight(weight); return e; } @@ -27,13 +27,13 @@ private edge makeEdge(String type, String v1, String v2, float weight) { * Builds a graph with a clear anomaly: one hub connected to everything, * plus a regular ring structure. * - * Hub (node 0) connects to nodes 1-8 with diverse edge types + * Hub (node 0) connects to nodes 1-8 with diverse Edge types * Nodes 1-8 form a ring (each connected to 2 neighbors) * Node 9 is an isolated leaf connected only to node 1 */ @Before public void setUp() { - graph = new UndirectedSparseGraph(); + graph = new UndirectedSparseGraph(); // Add hub String hub = "0"; @@ -45,7 +45,7 @@ public void setUp() { String node = String.valueOf(i); graph.addVertex(node); // Hub connects to each ring node with varying types - edge e = makeEdge(types[i - 1], hub, node, 1.0f); + Edge e = makeEdge(types[i - 1], hub, node, 1.0f); graph.addEdge(e, hub, node); } @@ -53,13 +53,13 @@ public void setUp() { for (int i = 1; i <= 8; i++) { String from = String.valueOf(i); String to = String.valueOf(i == 8 ? 1 : i + 1); - edge e = makeEdge("f", from, to, 1.0f); + Edge e = makeEdge("f", from, to, 1.0f); graph.addEdge(e, from, to); } // Leaf node graph.addVertex("9"); - edge leafEdge = makeEdge("s", "1", "9", 1.0f); + Edge leafEdge = makeEdge("s", "1", "9", 1.0f); graph.addEdge(leafEdge, "1", "9"); } @@ -92,22 +92,22 @@ 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); + Edge e = makeEdge("f", "A", "B", 1.0f); tiny.addEdge(e, "A", "B"); new GraphAnomalyDetector(tiny).analyze(); } @Test public void testAnalyzeThreeVerticesMinimum() { - Graph small = new UndirectedSparseGraph(); + Graph small = new UndirectedSparseGraph(); small.addVertex("A"); small.addVertex("B"); small.addVertex("C"); - edge e1 = makeEdge("f", "A", "B", 1.0f); - edge e2 = makeEdge("f", "B", "C", 1.0f); + Edge e1 = makeEdge("f", "A", "B", 1.0f); + Edge e2 = makeEdge("f", "B", "C", 1.0f); small.addEdge(e1, "A", "B"); small.addEdge(e2, "B", "C"); @@ -345,8 +345,8 @@ public void testResultCompareTo() { public void testHubHasHighDiversity() { GraphAnomalyDetector det = new GraphAnomalyDetector(graph).analyze(); GraphAnomalyDetector.AnomalyResult hub = det.getResult("0"); - // Hub connects with 5 different edge types - assertTrue("Hub should have high edge diversity", + // Hub connects with 5 different Edge types + assertTrue("Hub should have high Edge diversity", hub.getEdgeDiversity() > 0.5); } @@ -354,8 +354,8 @@ public void testHubHasHighDiversity() { public void testLeafHasZeroDiversity() { GraphAnomalyDetector det = new GraphAnomalyDetector(graph).analyze(); GraphAnomalyDetector.AnomalyResult leaf = det.getResult("9"); - // Leaf has only 1 edge type - assertEquals("Leaf with one edge type should have 0 diversity", + // Leaf has only 1 Edge type + assertEquals("Leaf with one Edge type should have 0 diversity", 0.0, leaf.getEdgeDiversity(), 0.001); } @@ -437,14 +437,14 @@ 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)); } for (int i = 0; i < 6; i++) { String from = String.valueOf(i); String to = String.valueOf((i + 1) % 6); - edge e = makeEdge("f", from, to, 1.0f); + Edge e = makeEdge("f", from, to, 1.0f); ring.addEdge(e, from, to); } @@ -460,12 +460,12 @@ 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; star.addVertex(leaf); - edge e = makeEdge("f", "center", leaf, 1.0f); + Edge e = makeEdge("f", "center", leaf, 1.0f); star.addEdge(e, "center", leaf); } @@ -480,14 +480,14 @@ 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); int edgeId = 0; for (int i = 0; i < nodes.length; i++) { for (int j = i + 1; j < nodes.length; j++) { - edge e = makeEdge("f", nodes[i], nodes[j], 1.0f); + Edge e = makeEdge("f", nodes[i], nodes[j], 1.0f); complete.addEdge(e, nodes[i], nodes[j]); } } diff --git a/Gvisual/test/gvisual/GraphAsciiRendererTest.java b/Gvisual/test/gvisual/GraphAsciiRendererTest.java index 5de1fb7..760ca26 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); } @@ -89,7 +89,7 @@ public void renderSingleNodeContainsLabel() { String output = renderer.render(); assertTrue("Should contain vertex label 'A'", output.contains("A")); assertTrue("Should contain node count", output.contains("1 nodes")); - assertTrue("Should contain edge count", output.contains("0 edges")); + assertTrue("Should contain Edge count", output.contains("0 edges")); } // --- Triangle graph basic render --- @@ -305,8 +305,8 @@ public void legendShowsEdgeTypeDistribution() { GraphAsciiRenderer renderer = new GraphAsciiRenderer(triangleGraph); renderer.setShowLegend(true); String output = renderer.render(); - // Triangle has f and c edge types - assertTrue("Legend should show edge types", output.contains("Edge types:")); + // Triangle has f and c Edge types + assertTrue("Legend should show Edge types", output.contains("Edge types:")); assertTrue("Should show 'f' type", output.contains("f=")); assertTrue("Should show 'c' type", output.contains("c=")); } @@ -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..d484a8a 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); + private Edge addEdge(String type, String v1, String v2, float weight) { + 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..ff5fd89 100644 --- a/Gvisual/test/gvisual/GraphClusterQualityAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphClusterQualityAnalyzerTest.java @@ -10,15 +10,15 @@ /** * Tests for GraphClusterQualityAnalyzer -- clustering quality metrics, - * NMI, Adjusted Rand Index, and edge cases. + * NMI, Adjusted Rand Index, and Edge cases. */ 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..b7697f8 100644 --- a/Gvisual/test/gvisual/GraphColoringAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphColoringAnalyzerTest.java @@ -11,16 +11,16 @@ /** * Tests for GraphColoringAnalyzer -- greedy coloring with multiple orderings, * DSatur, chromatic bounds, k-colorability, coloring verification, color - * class analysis, edge chromatic bounds, and report generation. + * class analysis, Edge chromatic bounds, and report generation. */ 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..83ea128 100644 --- a/Gvisual/test/gvisual/GraphDiffAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphDiffAnalyzerTest.java @@ -10,14 +10,14 @@ import static org.junit.Assert.*; /** - * Comprehensive tests for {@link GraphDiffAnalyzer} — node/edge diffs, + * Comprehensive tests for {@link GraphDiffAnalyzer} — node/Edge diffs, * Jaccard similarity, edit distance, degree changes, EdgeDiff normalization, * and DiffResult summary. */ 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); } @@ -173,7 +173,7 @@ public void testDisjointGraphs() { assertEquals(1, result.getRemovedEdges().size()); assertEquals(0.0, result.getNodeJaccard(), 0.001); assertEquals(0.0, result.getEdgeJaccard(), 0.001); - // edit distance = 2 added nodes + 2 removed nodes + 1 added edge + 1 removed edge = 6 + // edit distance = 2 added nodes + 2 removed nodes + 1 added Edge + 1 removed Edge = 6 assertEquals(6, result.getEditDistance()); } @@ -232,7 +232,7 @@ public void testEdgeRewiring() { @Test public void testSameNodesNewEdge() { - // Same vertices, different edge structure + // Same vertices, different Edge structure graphA.addVertex("A"); graphA.addVertex("B"); addEdge(graphB, "A", "B"); @@ -285,7 +285,7 @@ public void testJaccardHalfOverlap() { @Test public void testEdgeJaccardPartialOverlap() { - // A: A-B, B-C; B: A-B, B-D → common edge = 1, total unique = 3 + // A: A-B, B-C; B: A-B, B-D → common Edge = 1, total unique = 3 addEdge(graphA, "A", "B"); addEdge(graphA, "B", "C"); addEdge(graphB, "A", "B"); @@ -294,7 +294,7 @@ public void testEdgeJaccardPartialOverlap() { GraphDiffAnalyzer.DiffResult result = new GraphDiffAnalyzer(graphA, graphB).computeDiff(); - // edge Jaccard = 1/3 ≈ 0.333 + // Edge Jaccard = 1/3 ≈ 0.333 assertEquals(1.0 / 3.0, result.getEdgeJaccard(), 0.001); } @@ -316,7 +316,7 @@ public void testEditDistanceOneAddition() { addEdge(graphB, "A", "B"); addEdge(graphB, "B", "C"); - // 1 added node + 1 added edge = 2 + // 1 added node + 1 added Edge = 2 assertEquals(2, new GraphDiffAnalyzer(graphA, graphB).computeEditDistance()); } @@ -327,7 +327,7 @@ public void testEditDistanceSwap() { addEdge(graphB, "A", "B"); addEdge(graphB, "B", "D"); - // removed C + edge B-C, added D + edge B-D = 4 + // removed C + Edge B-C, added D + Edge B-D = 4 assertEquals(4, new GraphDiffAnalyzer(graphA, graphB).computeEditDistance()); } diff --git a/Gvisual/test/gvisual/GraphDistanceDistributionTest.java b/Gvisual/test/gvisual/GraphDistanceDistributionTest.java index b18d022..df16110 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); @@ -262,11 +262,11 @@ public void testNonexistentVertex() { assertEquals(-1, dd.getDistance("nonexistent", "v0")); } - // --- remoteness edge cases --- + // --- remoteness Edge cases --- @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..d73feee 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() { @@ -23,12 +23,12 @@ public void setUp() { // --- Helpers --- - private edge addEdge(String v1, String v2) { + private Edge addEdge(String v1, String v2) { return addEdge(v1, v2, "f"); } - private edge addEdge(String v1, String v2, String type) { - edge e = new edge(type, v1, v2); + private Edge addEdge(String v1, String v2, String type) { + 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..ddb2e44 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(); + // Build Edge lists (all "f" type in generated graphs) + 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..5eec675 100644 --- a/Gvisual/test/gvisual/GraphIsomorphismAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphIsomorphismAnalyzerTest.java @@ -16,16 +16,16 @@ public class GraphIsomorphismAnalyzerTest { // ── Helper methods ────────────────────────────────────────── /** - * Build an undirected graph from edge pairs. - * Each edge is [vertex1, vertex2]. + * 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 @@ -204,17 +204,17 @@ public void analyze_differentEdgeCount_notIsomorphic() { new GraphIsomorphismAnalyzer(g1, g2b).analyze(); assertFalse(result.isIsomorphic()); - assertTrue(result.getRejectionReason().contains("edge count")); + assertTrue(result.getRejectionReason().contains("Edge count")); } @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); @@ -430,13 +430,13 @@ public void degreeSequence_isUnmodifiable() { /** * Verify that a mapping preserves all edges: - * for every edge (u, v) in g1, (mapping[u], mapping[v]) must be - * an edge in g2. + * 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..96fe085 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 --- @@ -58,7 +58,7 @@ public void testEmptyGraphExport() { assertTrue(xml.contains("edgedefault=\"undirected\"")); assertTrue(xml.contains("")); assertFalse(xml.contains("")); + assertTrue(xml.contains("")); assertTrue(xml.contains("f")); assertTrue(xml.contains("Friend")); assertTrue(xml.contains("42.5")); @@ -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"); @@ -139,7 +139,7 @@ public void testEdgeWithoutLabelOmitted() { assertFalse(xml.contains("")); } - // --- All edge types --- + // --- All Edge types --- @Test public void testAllEdgeTypeLabels() { @@ -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"); @@ -284,7 +284,7 @@ public void testExportToFile() throws IOException { assertTrue(content.contains("")); assertTrue(content.contains("")); - assertTrue(content.contains("()); + 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 @@ -361,7 +361,7 @@ public void testExportVisibleOnly() { assertTrue(fullXml.contains("e0")); assertTrue(fullXml.contains("e1")); - // Visible-only export should have 1 edge + // Visible-only export should have 1 Edge String visibleXml = exporter.exportVisibleToString(); assertTrue(visibleXml.contains("e0")); assertFalse(visibleXml.contains("e1")); @@ -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)); @@ -391,15 +391,15 @@ public void testLargeGraphExport() { String xml = exporter.exportToString(); assertTrue(xml.contains("")); assertTrue(xml.contains("")); - assertTrue(xml.contains(" 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")); } @@ -68,7 +68,7 @@ public void testUnionKeepLeftWeight() { GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, GraphMerger.Strategy.UNION, GraphMerger.EdgeConflict.KEEP_LEFT); - edge bcEdge = result.getMergedGraph().findEdge("B", "C"); + Edge bcEdge = result.getMergedGraph().findEdge("B", "C"); assertNotNull(bcEdge); assertEquals(1.0f, bcEdge.getWeight(), 0.001f); // kept left (1.0) } @@ -78,7 +78,7 @@ public void testUnionKeepRightWeight() { GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, GraphMerger.Strategy.UNION, GraphMerger.EdgeConflict.KEEP_RIGHT); - edge bcEdge = result.getMergedGraph().findEdge("B", "C"); + Edge bcEdge = result.getMergedGraph().findEdge("B", "C"); assertNotNull(bcEdge); assertEquals(3.0f, bcEdge.getWeight(), 0.001f); } @@ -88,7 +88,7 @@ public void testUnionSumWeight() { GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, GraphMerger.Strategy.UNION, GraphMerger.EdgeConflict.SUM); - edge bcEdge = result.getMergedGraph().findEdge("B", "C"); + Edge bcEdge = result.getMergedGraph().findEdge("B", "C"); assertNotNull(bcEdge); assertEquals(4.0f, bcEdge.getWeight(), 0.001f); // 1+3 } @@ -98,7 +98,7 @@ public void testUnionAverageWeight() { GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, GraphMerger.Strategy.UNION, GraphMerger.EdgeConflict.AVERAGE); - edge bcEdge = result.getMergedGraph().findEdge("B", "C"); + Edge bcEdge = result.getMergedGraph().findEdge("B", "C"); assertNotNull(bcEdge); assertEquals(2.0f, bcEdge.getWeight(), 0.001f); // (1+3)/2 } @@ -108,7 +108,7 @@ public void testUnionMaxWeight() { GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, GraphMerger.Strategy.UNION, GraphMerger.EdgeConflict.MAX); - edge bcEdge = result.getMergedGraph().findEdge("B", "C"); + Edge bcEdge = result.getMergedGraph().findEdge("B", "C"); assertNotNull(bcEdge); assertEquals(3.0f, bcEdge.getWeight(), 0.001f); } @@ -118,7 +118,7 @@ public void testUnionMinWeight() { GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, GraphMerger.Strategy.UNION, GraphMerger.EdgeConflict.MIN); - edge bcEdge = result.getMergedGraph().findEdge("B", "C"); + Edge bcEdge = result.getMergedGraph().findEdge("B", "C"); assertNotNull(bcEdge); assertEquals(1.0f, bcEdge.getWeight(), 0.001f); } @@ -130,11 +130,11 @@ public void testIntersectionMerge() { GraphMerger.MergeResult result = GraphMerger.merge(graphA, graphB, GraphMerger.Strategy.INTERSECTION, GraphMerger.EdgeConflict.KEEP_LEFT); - // Shared vertices: B, C. Shared edge: B-C + // Shared vertices: B, C. Shared Edge: B-C 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..2ca3fb3 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,8 +152,8 @@ public void testContractEdgeReducesVertices() { @Test public void testContractEdgeInTriangle() { GraphMinorAnalyzer a = new GraphMinorAnalyzer(makeComplete(3)); - Graph result = a.contractEdge("v0", "v1"); - // K3 contract → K2 (v0 and v2 with one edge) + Graph result = a.contractEdge("v0", "v1"); + // K3 contract → K2 (v0 and v2 with one Edge) assertEquals(2, result.getVertexCount()); assertEquals(1, result.getEdgeCount()); } @@ -161,8 +161,8 @@ public void testContractEdgeInTriangle() { @Test public void testContractEdgeK4ToK3() { GraphMinorAnalyzer a = new GraphMinorAnalyzer(makeComplete(4)); - Graph result = a.contractEdge("v0", "v1"); - // K4 contract one edge → K3 + 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,24 +331,24 @@ 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 ────────────────────────────────────────────────── + // ── Subdivide Edge ────────────────────────────────────────────────── @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..15faab7 100644 --- a/Gvisual/test/gvisual/GraphNeighborhoodAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphNeighborhoodAnalyzerTest.java @@ -14,15 +14,15 @@ */ public class GraphNeighborhoodAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { graph = new UndirectedSparseGraph<>(); } - private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + private Edge addEdge(String v1, String 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); @@ -506,7 +506,7 @@ public void testCycleGrowthProfile() { } // ------------------------------------------------------------------ - // Edge case: single edge + // Edge case: single Edge // ------------------------------------------------------------------ @Test diff --git a/Gvisual/test/gvisual/GraphNetworkProfilerTest.java b/Gvisual/test/gvisual/GraphNetworkProfilerTest.java index 97b76ca..5220a46 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..5841792 100644 --- a/Gvisual/test/gvisual/GraphPartitionerTest.java +++ b/Gvisual/test/gvisual/GraphPartitionerTest.java @@ -10,11 +10,11 @@ /** * Tests for GraphPartitioner — BFS, Kernighan-Lin, and spectral - * partitioning strategies with balance, edge cut, and conductance metrics. + * partitioning strategies with balance, Edge cut, and conductance metrics. */ 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); } @@ -154,7 +154,7 @@ public void testBFSTriangleTwoParts() { GraphPartitioner.PartitionResult result = new GraphPartitioner(graph).partition(2, GraphPartitioner.Strategy.BFS); assertValidPartition(result, 2); - // At least 1 edge must be cut (triangle can't be split without cutting) + // At least 1 Edge must be cut (triangle can't be split without cutting) assertTrue(result.getEdgeCuts() >= 1); } @@ -208,7 +208,7 @@ public void testKLImprovesBFS() { GraphPartitioner p = new GraphPartitioner(graph); GraphPartitioner.PartitionResult bfs = p.partition(2, GraphPartitioner.Strategy.BFS); GraphPartitioner.PartitionResult kl = p.partition(2, GraphPartitioner.Strategy.KERNIGHAN_LIN); - // KL should have same or fewer edge cuts than BFS + // KL should have same or fewer Edge cuts than BFS assertTrue("KL cuts " + kl.getEdgeCuts() + " >= BFS cuts " + bfs.getEdgeCuts(), kl.getEdgeCuts() <= bfs.getEdgeCuts()); } @@ -404,7 +404,7 @@ public void testDefaultStrategyIsBFS() { GraphPartitioner p = new GraphPartitioner(graph); GraphPartitioner.PartitionResult r1 = p.partition(2); GraphPartitioner.PartitionResult r2 = p.partition(2, GraphPartitioner.Strategy.BFS); - // Same edge cuts (deterministic) + // Same Edge cuts (deterministic) assertEquals(r1.getEdgeCuts(), r2.getEdgeCuts()); } diff --git a/Gvisual/test/gvisual/GraphPathExplorerTest.java b/Gvisual/test/gvisual/GraphPathExplorerTest.java index b49c6a3..2e33c25 100644 --- a/Gvisual/test/gvisual/GraphPathExplorerTest.java +++ b/Gvisual/test/gvisual/GraphPathExplorerTest.java @@ -16,15 +16,15 @@ */ public class GraphPathExplorerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { graph = new UndirectedSparseGraph<>(); } - private edge makeEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + private Edge makeEdge(String type, String v1, String v2, float weight) { + Edge e = new Edge(type, v1, v2); e.setWeight(weight); return e; } @@ -116,7 +116,7 @@ public void testAllSimplePathsComplete() { public void testAllSimplePathsNoPath() { graph.addVertex("A"); graph.addVertex("B"); - // No edge between them + // No Edge between them GraphPathExplorer explorer = new GraphPathExplorer(graph); List paths = explorer.findAllSimplePaths("A", "B"); assertTrue("Disconnected vertices should yield no paths", paths.isEmpty()); @@ -290,7 +290,7 @@ public void testAvoidNode() { public void testAvoidEdge() { buildDiamondGraph(); GraphPathExplorer explorer = new GraphPathExplorer(graph); - // Avoid edge A-B → must go A-C-D + // Avoid Edge A-B → must go A-C-D Set avoidEdges = new HashSet<>(); avoidEdges.add(GraphPathExplorer.edgeKey("A", "B")); GraphPathExplorer.Path p = explorer.findPathAvoiding( diff --git a/Gvisual/test/gvisual/GraphQueryEngineTest.java b/Gvisual/test/gvisual/GraphQueryEngineTest.java index bffce7e..99d63e6 100644 --- a/Gvisual/test/gvisual/GraphQueryEngineTest.java +++ b/Gvisual/test/gvisual/GraphQueryEngineTest.java @@ -10,11 +10,11 @@ import static org.junit.Assert.*; /** - * Tests for GraphQueryEngine — node and edge query builders. + * Tests for GraphQueryEngine — node and Edge query builders. */ 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 } @@ -165,7 +165,7 @@ public void testNodeSummary() { @Test public void testEdgeSummary() { String summary = engine.edges().ofType("s").summary(); - assertTrue(summary.contains("1 edge")); + assertTrue(summary.contains("1 Edge")); } @Test @@ -176,13 +176,13 @@ 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"); assertEquals(1, engine.edges().temporal().count()); - assertEquals(1, engine.edges().activeAt(1500L).count()); // only temporal edge + assertEquals(1, engine.edges().activeAt(1500L).count()); // only temporal Edge assertEquals(0, engine.edges().temporal().activeAt(3000L).count()); } } diff --git a/Gvisual/test/gvisual/GraphResilienceAnalyzerTest.java b/Gvisual/test/gvisual/GraphResilienceAnalyzerTest.java index 7253b32..9f3b79b 100644 --- a/Gvisual/test/gvisual/GraphResilienceAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphResilienceAnalyzerTest.java @@ -12,15 +12,15 @@ * Unit tests for {@link GraphResilienceAnalyzer}. * * Tests cover all three attack strategies (degree, betweenness, random), - * robustness index computation, summary/CSV export, and edge cases + * robustness index computation, summary/CSV export, and Edge cases * (empty graphs, single nodes, disconnected graphs, star/complete topologies). */ public class GraphResilienceAnalyzerTest { private int edgeCounter = 0; - private edge makeEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + private Edge makeEdge(String v1, String 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..7819ba9 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); } @@ -449,12 +449,12 @@ public void randomNode_inducesEdgesCorrectly() { @Test public void randomEdge_inducesExtraEdges() { - // Build triangle A-B-C, sample edge A-B + // Build triangle A-B-C, sample Edge A-B // Should also induce A-C and B-C if nodes A,B,C are all included addEdge("A", "B"); addEdge("B", "C"); addEdge("A", "C"); - // Add isolated node to make edge fraction meaningful + // Add isolated node to make Edge fraction meaningful graph.addVertex("D"); GraphSampler sampler = new GraphSampler(graph, new Random(1)); 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..9f2b2d6 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"); @@ -76,7 +76,7 @@ public void setUp() { // Edge Importance @Test public void testImportancePath() { - Map s = new GraphSparsificationAnalyzer(path).scoreEdgeImportance(); + Map s = new GraphSparsificationAnalyzer(path).scoreEdgeImportance(); assertEquals(3, s.size()); for (double v : s.values()) { assertTrue(v >= 0); assertTrue(v <= 1.0); } } @@ -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..e4f7fd0 100644 --- a/Gvisual/test/gvisual/GraphStatsTest.java +++ b/Gvisual/test/gvisual/GraphStatsTest.java @@ -16,21 +16,21 @@ */ public class GraphStatsTest { - private Graph graph; - private Vector friendEdges; - private Vector fsEdges; - private Vector classmateEdges; - private Vector strangerEdges; - private Vector studyGEdges; + private Graph graph; + private Vector friendEdges; + private Vector fsEdges; + private Vector classmateEdges; + private Vector strangerEdges; + private Vector studyGEdges; @Before public void setUp() { - graph = new UndirectedSparseGraph(); - friendEdges = new Vector(); - fsEdges = new Vector(); - classmateEdges = new Vector(); - strangerEdges = new Vector(); - studyGEdges = new Vector(); + graph = new UndirectedSparseGraph(); + friendEdges = new Vector(); + fsEdges = new Vector(); + classmateEdges = new Vector(); + strangerEdges = new Vector(); + studyGEdges = new Vector(); } private GraphStats createStats() { @@ -40,13 +40,13 @@ private GraphStats createStats() { // ── Helper ────────────────────────────────────────────────── - private edge makeEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + private Edge makeEdge(String type, String v1, String v2, float weight) { + 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()); } @@ -102,11 +102,11 @@ public void testDensitySingleNode() { assertEquals(0.0, stats.getDensity(), 0.001); } - // ── Single edge ───────────────────────────────────────────── + // ── Single Edge ───────────────────────────────────────────── @Test public void testSingleEdge() { - edge e = makeEdge("f", "A", "B", 50.0f); + Edge e = makeEdge("f", "A", "B", 50.0f); friendEdges.add(e); addToGraph(e); @@ -120,8 +120,8 @@ public void testSingleEdge() { @Test public void testSingleEdge_density() { - // 2 nodes, 1 edge: density = 2*1 / (2*1) = 1.0 - edge e = makeEdge("f", "A", "B", 10); + // 2 nodes, 1 Edge: density = 2*1 / (2*1) = 1.0 + Edge e = makeEdge("f", "A", "B", 10); friendEdges.add(e); addToGraph(e); GraphStats stats = createStats(); @@ -130,8 +130,8 @@ public void testSingleEdge_density() { @Test public void testSingleEdge_averageDegree() { - // 2 nodes, 1 edge: avg = 2*1/2 = 1.0 - edge e = makeEdge("f", "A", "B", 10); + // 2 nodes, 1 Edge: avg = 2*1/2 = 1.0 + Edge e = makeEdge("f", "A", "B", 10); friendEdges.add(e); addToGraph(e); GraphStats stats = createStats(); @@ -142,9 +142,9 @@ public void testSingleEdge_averageDegree() { @Test public void testDensityTriangle() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "B", "C", 10); - edge e3 = makeEdge("f", "A", "C", 10); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "B", "C", 10); + Edge e3 = makeEdge("f", "A", "C", 10); addToGraph(e1); addToGraph(e2); addToGraph(e3); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); @@ -155,9 +155,9 @@ public void testDensityTriangle() { @Test public void testTriangle_averageDegree() { // 3 nodes, 3 edges: avg = 2*3/3 = 2.0 - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "B", "C", 10); - edge e3 = makeEdge("f", "A", "C", 10); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "B", "C", 10); + Edge e3 = makeEdge("f", "A", "C", 10); addToGraph(e1); addToGraph(e2); addToGraph(e3); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); @@ -167,9 +167,9 @@ public void testTriangle_averageDegree() { @Test public void testTriangle_maxDegree() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "B", "C", 10); - edge e3 = makeEdge("f", "A", "C", 10); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "B", "C", 10); + Edge e3 = makeEdge("f", "A", "C", 10); addToGraph(e1); addToGraph(e2); addToGraph(e3); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); @@ -179,9 +179,9 @@ public void testTriangle_maxDegree() { @Test public void testTriangle_noIsolatedNodes() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "B", "C", 10); - edge e3 = makeEdge("f", "A", "C", 10); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "B", "C", 10); + Edge e3 = makeEdge("f", "A", "C", 10); addToGraph(e1); addToGraph(e2); addToGraph(e3); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); @@ -194,8 +194,8 @@ public void testTriangle_noIsolatedNodes() { @Test public void testAverageDegree() { // 3 nodes, 2 edges: degrees are 2, 1, 1 -> avg = 4/3 - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("c", "A", "C", 20); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("c", "A", "C", 20); addToGraph(e1); addToGraph(e2); friendEdges.add(e1); classmateEdges.add(e2); @@ -207,9 +207,9 @@ public void testAverageDegree() { @Test public void testAverageDegree_fourNodesPath() { // A-B-C-D (path): 3 edges, 4 nodes, degrees: 1,2,2,1 avg = 6/4 = 1.5 - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "B", "C", 10); - edge e3 = makeEdge("f", "C", "D", 10); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "B", "C", 10); + Edge e3 = makeEdge("f", "C", "D", 10); addToGraph(e1); addToGraph(e2); addToGraph(e3); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); @@ -221,9 +221,9 @@ public void testAverageDegree_fourNodesPath() { @Test public void testTopNodes() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "A", "C", 10); - edge e3 = makeEdge("f", "A", "D", 10); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "A", "C", 10); + Edge e3 = makeEdge("f", "A", "D", 10); addToGraph(e1); addToGraph(e2); addToGraph(e3); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); @@ -236,7 +236,7 @@ public void testTopNodes() { @Test public void testTopNodes_requestMoreThanExist() { - edge e1 = makeEdge("f", "A", "B", 10); + Edge e1 = makeEdge("f", "A", "B", 10); addToGraph(e1); friendEdges.add(e1); @@ -247,7 +247,7 @@ public void testTopNodes_requestMoreThanExist() { @Test public void testTopNodes_requestZero() { - edge e1 = makeEdge("f", "A", "B", 10); + Edge e1 = makeEdge("f", "A", "B", 10); addToGraph(e1); friendEdges.add(e1); @@ -258,7 +258,7 @@ public void testTopNodes_requestZero() { @Test public void testTopNodes_requestNegative() { - edge e1 = makeEdge("f", "A", "B", 10); + Edge e1 = makeEdge("f", "A", "B", 10); addToGraph(e1); friendEdges.add(e1); @@ -269,8 +269,8 @@ public void testTopNodes_requestNegative() { @Test public void testTopNodes_requestOne() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "A", "C", 10); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "A", "C", 10); addToGraph(e1); addToGraph(e2); friendEdges.add(e1); friendEdges.add(e2); @@ -284,9 +284,9 @@ public void testTopNodes_requestOne() { @Test public void testTopNodes_allSameDegree() { // Triangle: all have degree 2 - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "B", "C", 10); - edge e3 = makeEdge("f", "A", "C", 10); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "B", "C", 10); + Edge e3 = makeEdge("f", "A", "C", 10); addToGraph(e1); addToGraph(e2); addToGraph(e3); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); @@ -316,12 +316,12 @@ public void testTopNodes_onlyIsolatedNodes() { @Test public void testTopNodes_descending() { // Hub A connects to 4, B connects to 2, C connects to 1 - edge e1 = makeEdge("f", "A", "X", 10); - edge e2 = makeEdge("f", "A", "Y", 10); - edge e3 = makeEdge("f", "A", "Z", 10); - edge e4 = makeEdge("f", "A", "W", 10); - edge e5 = makeEdge("f", "B", "X", 10); - edge e6 = makeEdge("f", "B", "Y", 10); + Edge e1 = makeEdge("f", "A", "X", 10); + Edge e2 = makeEdge("f", "A", "Y", 10); + Edge e3 = makeEdge("f", "A", "Z", 10); + Edge e4 = makeEdge("f", "A", "W", 10); + Edge e5 = makeEdge("f", "B", "X", 10); + Edge e6 = makeEdge("f", "B", "Y", 10); addToGraph(e1); addToGraph(e2); addToGraph(e3); addToGraph(e4); addToGraph(e5); addToGraph(e6); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); @@ -350,7 +350,7 @@ public void testIsolatedNodes() { @Test public void testIsolatedNodes_mixedConnectivity() { // A-B connected, C and D isolated - edge e = makeEdge("f", "A", "B", 10); + Edge e = makeEdge("f", "A", "B", 10); addToGraph(e); friendEdges.add(e); graph.addVertex("C"); @@ -362,8 +362,8 @@ public void testIsolatedNodes_mixedConnectivity() { @Test public void testIsolatedNodes_noneIsolated() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "B", "C", 10); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "B", "C", 10); addToGraph(e1); addToGraph(e2); friendEdges.add(e1); friendEdges.add(e2); @@ -375,8 +375,8 @@ public void testIsolatedNodes_noneIsolated() { @Test public void testAverageWeight() { - edge e1 = makeEdge("f", "A", "B", 30.0f); - edge e2 = makeEdge("s", "C", "D", 10.0f); + Edge e1 = makeEdge("f", "A", "B", 30.0f); + Edge e2 = makeEdge("s", "C", "D", 10.0f); addToGraph(e1); addToGraph(e2); friendEdges.add(e1); strangerEdges.add(e2); @@ -386,7 +386,7 @@ public void testAverageWeight() { @Test public void testAverageWeight_singleEdge() { - edge e = makeEdge("f", "A", "B", 42.0f); + Edge e = makeEdge("f", "A", "B", 42.0f); addToGraph(e); friendEdges.add(e); @@ -396,8 +396,8 @@ public void testAverageWeight_singleEdge() { @Test public void testAverageWeight_zeroWeight() { - edge e1 = makeEdge("f", "A", "B", 0.0f); - edge e2 = makeEdge("f", "C", "D", 0.0f); + Edge e1 = makeEdge("f", "A", "B", 0.0f); + Edge e2 = makeEdge("f", "C", "D", 0.0f); addToGraph(e1); addToGraph(e2); friendEdges.add(e1); friendEdges.add(e2); @@ -414,10 +414,10 @@ public void testAverageWeight_noEdges() { @Test public void testAverageWeight_multipleEdges() { - edge e1 = makeEdge("f", "A", "B", 10.0f); - edge e2 = makeEdge("f", "B", "C", 20.0f); - edge e3 = makeEdge("f", "C", "D", 30.0f); - edge e4 = makeEdge("f", "D", "E", 40.0f); + Edge e1 = makeEdge("f", "A", "B", 10.0f); + Edge e2 = makeEdge("f", "B", "C", 20.0f); + Edge e3 = makeEdge("f", "C", "D", 30.0f); + Edge e4 = makeEdge("f", "D", "E", 40.0f); addToGraph(e1); addToGraph(e2); addToGraph(e3); addToGraph(e4); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); friendEdges.add(e4); @@ -429,11 +429,11 @@ public void testAverageWeight_multipleEdges() { @Test public void testCategoryCountsIndependent() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("fs", "C", "D", 5); - edge e3 = makeEdge("c", "E", "F", 20); - edge e4 = makeEdge("s", "G", "H", 2); - edge e5 = makeEdge("sg", "I", "J", 15); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("fs", "C", "D", 5); + Edge e3 = makeEdge("c", "E", "F", 20); + Edge e4 = makeEdge("s", "G", "H", 2); + Edge e5 = makeEdge("sg", "I", "J", 15); friendEdges.add(e1); fsEdges.add(e2); @@ -457,9 +457,9 @@ public void testCategoryCountsIndependent() { @Test public void testCategoryCount_multipleFriends() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "C", "D", 20); - edge e3 = makeEdge("f", "E", "F", 30); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "C", "D", 20); + Edge e3 = makeEdge("f", "E", "F", 30); friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); addToGraph(e1); addToGraph(e2); addToGraph(e3); @@ -483,12 +483,12 @@ public void testCategoryCount_allZero() { assertEquals(0, stats.getTotalEdgeCount()); } - // ── Density edge cases ────────────────────────────────────── + // ── Density Edge cases ────────────────────────────────────── @Test public void testDensity_sparseGraph() { - // 4 nodes, 1 edge: density = 2*1 / (4*3) = 1/6 - edge e = makeEdge("f", "A", "B", 10); + // 4 nodes, 1 Edge: density = 2*1 / (4*3) = 1/6 + Edge e = makeEdge("f", "A", "B", 10); addToGraph(e); friendEdges.add(e); graph.addVertex("C"); @@ -505,7 +505,7 @@ public void testDensity_completeK4() { int id = 0; for (int i = 0; i < nodes.length; i++) { for (int j = i + 1; j < nodes.length; j++) { - edge e = makeEdge("f", nodes[i], nodes[j], 10); + Edge e = makeEdge("f", nodes[i], nodes[j], 10); e.setLabel("e" + id++); addToGraph(e); friendEdges.add(e); @@ -521,7 +521,7 @@ public void testDensity_starGraph() { // Center connects to 5 others: 6 nodes, 5 edges // density = 2*5 / (6*5) = 10/30 = 1/3 for (int i = 1; i <= 5; i++) { - edge e = makeEdge("f", "center", "n" + i, 10); + Edge e = makeEdge("f", "center", "n" + i, 10); e.setLabel("e" + i); addToGraph(e); friendEdges.add(e); @@ -531,13 +531,13 @@ public void testDensity_starGraph() { assertEquals(1.0 / 3.0, stats.getDensity(), 0.001); } - // ── Max degree edge cases ─────────────────────────────────── + // ── Max degree Edge cases ─────────────────────────────────── @Test public void testMaxDegree_starGraph() { // Center has degree 5 for (int i = 1; i <= 5; i++) { - edge e = makeEdge("f", "hub", "leaf" + i, 10); + Edge e = makeEdge("f", "hub", "leaf" + i, 10); e.setLabel("e" + i); addToGraph(e); friendEdges.add(e); @@ -565,8 +565,8 @@ public void testMaxDegree_onlyIsolated() { @Test public void testCaching_multipleCallsReturnSameResult() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("f", "A", "C", 20); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("f", "A", "C", 20); addToGraph(e1); addToGraph(e2); friendEdges.add(e1); friendEdges.add(e2); @@ -585,8 +585,8 @@ public void testCaching_multipleCallsReturnSameResult() { @Test public void testCaching_weightMultipleCalls() { - edge e1 = makeEdge("f", "A", "B", 15.0f); - edge e2 = makeEdge("f", "C", "D", 25.0f); + Edge e1 = makeEdge("f", "A", "B", 15.0f); + Edge e2 = makeEdge("f", "C", "D", 25.0f); addToGraph(e1); addToGraph(e2); friendEdges.add(e1); friendEdges.add(e2); @@ -613,9 +613,9 @@ public void testFiltered_noEdgesVisible() { @Test public void testFiltered_partialVisible() { - edge e1 = makeEdge("f", "A", "B", 30); - edge e2 = makeEdge("f", "C", "D", 10); - edge e3 = makeEdge("f", "E", "F", 50); // not added to graph + Edge e1 = makeEdge("f", "A", "B", 30); + Edge e2 = makeEdge("f", "C", "D", 10); + Edge e3 = makeEdge("f", "E", "F", 50); // not added to graph friendEdges.add(e1); friendEdges.add(e2); friendEdges.add(e3); addToGraph(e1); addToGraph(e2); @@ -632,7 +632,7 @@ public void testFiltered_partialVisible() { public void testLargerGraph_tenNodes() { // Build a star: node0 connects to nodes 1-9 for (int i = 1; i <= 9; i++) { - edge e = makeEdge("f", "n0", "n" + i, i * 10.0f); + Edge e = makeEdge("f", "n0", "n" + i, i * 10.0f); e.setLabel("e" + i); addToGraph(e); friendEdges.add(e); @@ -663,7 +663,7 @@ public void testLargerGraph_tenNodes() { public void testLargerGraph_chainOf10() { // Linear chain: n0-n1-n2-...-n9 for (int i = 0; i < 9; i++) { - edge e = makeEdge("f", "n" + i, "n" + (i + 1), 10); + Edge e = makeEdge("f", "n" + i, "n" + (i + 1), 10); e.setLabel("e" + i); addToGraph(e); friendEdges.add(e); @@ -676,12 +676,12 @@ public void testLargerGraph_chainOf10() { assertEquals(0, stats.getIsolatedNodeCount()); } - // ── Node and edge count accuracy ──────────────────────────── + // ── Node and Edge count accuracy ──────────────────────────── @Test public void testNodeCount_verticesFromEdgesOnly() { // Vertices only added implicitly through edges - edge e = makeEdge("f", "X", "Y", 5); + Edge e = makeEdge("f", "X", "Y", 5); addToGraph(e); friendEdges.add(e); @@ -694,7 +694,7 @@ public void testNodeCount_mixedExplicitAndEdge() { graph.addVertex("A"); graph.addVertex("B"); graph.addVertex("C"); - edge e = makeEdge("f", "A", "B", 10); + Edge e = makeEdge("f", "A", "B", 10); addToGraph(e); friendEdges.add(e); @@ -708,11 +708,11 @@ public void testNodeCount_mixedExplicitAndEdge() { @Test public void testMixedCategories_allInGraph() { - edge e1 = makeEdge("f", "A", "B", 10); - edge e2 = makeEdge("fs", "C", "D", 20); - edge e3 = makeEdge("c", "E", "F", 30); - edge e4 = makeEdge("s", "G", "H", 40); - edge e5 = makeEdge("sg", "I", "J", 50); + Edge e1 = makeEdge("f", "A", "B", 10); + Edge e2 = makeEdge("fs", "C", "D", 20); + Edge e3 = makeEdge("c", "E", "F", 30); + Edge e4 = makeEdge("s", "G", "H", 40); + Edge e5 = makeEdge("sg", "I", "J", 50); e1.setLabel("e1"); e2.setLabel("e2"); e3.setLabel("e3"); e4.setLabel("e4"); e5.setLabel("e5"); addToGraph(e1); addToGraph(e2); addToGraph(e3); diff --git a/Gvisual/test/gvisual/GraphSummarizerTest.java b/Gvisual/test/gvisual/GraphSummarizerTest.java index 1229aa0..701714b 100644 --- a/Gvisual/test/gvisual/GraphSummarizerTest.java +++ b/Gvisual/test/gvisual/GraphSummarizerTest.java @@ -13,27 +13,27 @@ */ 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() { return new GraphSummarizer(graph, friends, fs, classmates, strangers, studyG); } - private edge addEdge(String v1, String v2, String typeCode) { + 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; @@ -63,7 +63,7 @@ public void testEmptyGraphOneLiner() { @Test public void testSmallNetwork() { - edge e1 = addEdge("A", "B", "f"); + Edge e1 = addEdge("A", "B", "f"); friends.add(e1); GraphSummarizer s = makeSummarizer(); String overview = s.getOverviewSection(); @@ -78,7 +78,7 @@ public void testMediumNetwork() { graph.addVertex("N" + i); } for (int i = 0; i < 19; i++) { - edge e = addEdge("N" + i, "N" + (i + 1), "c"); + Edge e = addEdge("N" + i, "N" + (i + 1), "c"); classmates.add(e); } GraphSummarizer s = makeSummarizer(); @@ -87,9 +87,9 @@ public void testMediumNetwork() { @Test public void testDensitySection() { - edge e1 = addEdge("A", "B", "f"); - edge e2 = addEdge("B", "C", "f"); - edge e3 = addEdge("A", "C", "f"); + Edge e1 = addEdge("A", "B", "f"); + Edge e2 = addEdge("B", "C", "f"); + Edge e3 = addEdge("A", "C", "f"); friends.add(e1); friends.add(e2); friends.add(e3); @@ -102,7 +102,7 @@ public void testDensitySection() { @Test public void testConnectivitySingleComponent() { - edge e1 = addEdge("A", "B", "f"); + Edge e1 = addEdge("A", "B", "f"); friends.add(e1); GraphSummarizer s = makeSummarizer(); String conn = s.getConnectivitySection(); @@ -111,7 +111,7 @@ public void testConnectivitySingleComponent() { @Test public void testConnectivityMultipleComponents() { - edge e1 = addEdge("A", "B", "f"); + Edge e1 = addEdge("A", "B", "f"); friends.add(e1); graph.addVertex("C"); // isolated GraphSummarizer s = makeSummarizer(); @@ -122,7 +122,7 @@ public void testConnectivityMultipleComponents() { @Test public void testCompositionAllFriends() { - edge e1 = addEdge("A", "B", "f"); + Edge e1 = addEdge("A", "B", "f"); friends.add(e1); GraphSummarizer s = makeSummarizer(); String comp = s.getCompositionSection(); @@ -132,9 +132,9 @@ public void testCompositionAllFriends() { @Test public void testCompositionMixed() { - edge e1 = addEdge("A", "B", "f"); + Edge e1 = addEdge("A", "B", "f"); friends.add(e1); - edge e2 = addEdge("B", "C", "s"); + Edge e2 = addEdge("B", "C", "s"); strangers.add(e2); GraphSummarizer s = makeSummarizer(); String comp = s.getCompositionSection(); @@ -152,9 +152,9 @@ public void testCompositionEmpty() { @Test public void testHubSection() { - edge e1 = addEdge("Hub", "A", "f"); - edge e2 = addEdge("Hub", "B", "f"); - edge e3 = addEdge("Hub", "C", "f"); + Edge e1 = addEdge("Hub", "A", "f"); + Edge e2 = addEdge("Hub", "B", "f"); + Edge e3 = addEdge("Hub", "C", "f"); friends.add(e1); friends.add(e2); friends.add(e3); @@ -174,9 +174,9 @@ public void testHubSectionEmpty() { @Test public void testStructuralObservationsTree() { // 4-node tree: A-B, B-C, C-D (3 edges, 4 nodes, connected) - edge e1 = addEdge("A", "B", "f"); - edge e2 = addEdge("B", "C", "f"); - edge e3 = addEdge("C", "D", "f"); + Edge e1 = addEdge("A", "B", "f"); + Edge e2 = addEdge("B", "C", "f"); + Edge e3 = addEdge("C", "D", "f"); friends.add(e1); friends.add(e2); friends.add(e3); @@ -188,11 +188,11 @@ public void testStructuralObservationsTree() { @Test public void testStructuralObservationsNearComplete() { // 4-node near-complete: 5 out of 6 edges → density 0.833 - edge e1 = addEdge("A", "B", "f"); - edge e2 = addEdge("A", "C", "f"); - edge e3 = addEdge("A", "D", "f"); - edge e4 = addEdge("B", "C", "f"); - edge e5 = addEdge("B", "D", "f"); + Edge e1 = addEdge("A", "B", "f"); + Edge e2 = addEdge("A", "C", "f"); + Edge e3 = addEdge("A", "D", "f"); + Edge e4 = addEdge("B", "C", "f"); + Edge e5 = addEdge("B", "D", "f"); friends.add(e1); friends.add(e2); friends.add(e3); friends.add(e4); friends.add(e5); GraphSummarizer s = makeSummarizer(); @@ -202,7 +202,7 @@ public void testStructuralObservationsNearComplete() { @Test public void testFullSummaryContainsAllSections() { - edge e1 = addEdge("A", "B", "f"); + Edge e1 = addEdge("A", "B", "f"); friends.add(e1); GraphSummarizer s = makeSummarizer(); String full = s.generateSummary(); @@ -222,7 +222,7 @@ public void testNullEdgeListsHandledGracefully() { @Test public void testOneLinerFormat() { - edge e1 = addEdge("A", "B", "f"); + Edge e1 = addEdge("A", "B", "f"); friends.add(e1); GraphSummarizer s = makeSummarizer(); String line = s.getOneLiner(); @@ -234,10 +234,10 @@ public void testOneLinerFormat() { @Test public void testAverageWeightObservation() { - edge e1 = addEdge("A", "B", "f"); + Edge e1 = addEdge("A", "B", "f"); friends.add(e1); GraphSummarizer s = makeSummarizer(); String obs = s.getStructuralObservations(); - assertTrue(obs.contains("Average edge weight")); + assertTrue(obs.contains("Average Edge weight")); } } diff --git a/Gvisual/test/gvisual/GraphSymmetryAnalyzerTest.java b/Gvisual/test/gvisual/GraphSymmetryAnalyzerTest.java index 94fc8f8..c157424 100644 --- a/Gvisual/test/gvisual/GraphSymmetryAnalyzerTest.java +++ b/Gvisual/test/gvisual/GraphSymmetryAnalyzerTest.java @@ -14,15 +14,15 @@ */ public class GraphSymmetryAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { graph = new UndirectedSparseGraph<>(); } - private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + private Edge addEdge(String v1, String 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); @@ -108,7 +108,7 @@ public void singleVertex_singleOrbit() { } // ═══════════════════════════════════════ - // Complete graph K_n (vertex-transitive, edge-transitive) + // Complete graph K_n (vertex-transitive, Edge-transitive) // ═══════════════════════════════════════ @Test @@ -147,7 +147,7 @@ public void completeK5_noFixedPoints() { } // ═══════════════════════════════════════ - // Cycle C_n (vertex-transitive, edge-transitive) + // Cycle C_n (vertex-transitive, Edge-transitive) // ═══════════════════════════════════════ @Test @@ -214,7 +214,7 @@ public void pathP4_twoOrbits() { } // ═══════════════════════════════════════ - // Star K_{1,n} (not vertex-transitive, edge-transitive) + // Star K_{1,n} (not vertex-transitive, Edge-transitive) // ═══════════════════════════════════════ @Test @@ -250,7 +250,7 @@ public void starK1_4_symmetryFactor() { } // ═══════════════════════════════════════ - // Petersen graph (vertex-transitive, edge-transitive) + // Petersen graph (vertex-transitive, Edge-transitive) // ═══════════════════════════════════════ private void buildPetersen() { @@ -512,7 +512,7 @@ public void vertexOrbitMap_unmodifiable() { } // ═══════════════════════════════════════ - // Bipartite K_{3,3} (vertex-transitive, edge-transitive) + // Bipartite K_{3,3} (vertex-transitive, Edge-transitive) // ═══════════════════════════════════════ @Test @@ -526,7 +526,7 @@ public void bipartiteK33_vertexTransitive() { } // ═══════════════════════════════════════ - // Cube Q3 (vertex-transitive, edge-transitive) + // Cube Q3 (vertex-transitive, Edge-transitive) // ═══════════════════════════════════════ @Test diff --git a/Gvisual/test/gvisual/GraphUtilsTest.java b/Gvisual/test/gvisual/GraphUtilsTest.java index ce34c65..3ecaf52 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..b719a36 100644 --- a/Gvisual/test/gvisual/GrowthRateAnalyzerTest.java +++ b/Gvisual/test/gvisual/GrowthRateAnalyzerTest.java @@ -12,33 +12,33 @@ /** * Comprehensive tests for GrowthRateAnalyzer. * Covers: constructor validation, analyze() snapshots, edgeGrowthRate() - * linear regression, density, clustering coefficient, edge cases. + * linear regression, density, clustering coefficient, Edge cases. */ 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); + private Edge makeEdge(String type, String v1, String v2, long start, long end) { + 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); + private Edge makeEdge(String type, String v1, String v2, long timestamp) { + 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); @@ -67,7 +67,7 @@ public void testConstructor_negativeWindows() { @Test public void testConstructor_validArguments() { - edge e = makeEdge("f", "A", "B", 100L, 200L); + Edge e = makeEdge("f", "A", "B", 100L, 200L); addEdge(graph, e); TemporalGraph tg = new TemporalGraph(graph); GrowthRateAnalyzer analyzer = new GrowthRateAnalyzer(tg, 3); @@ -76,7 +76,7 @@ public void testConstructor_validArguments() { @Test public void testConstructor_singleWindow() { - edge e = makeEdge("f", "A", "B", 100L, 200L); + Edge e = makeEdge("f", "A", "B", 100L, 200L); addEdge(graph, e); TemporalGraph tg = new TemporalGraph(graph); GrowthRateAnalyzer analyzer = new GrowthRateAnalyzer(tg, 1); @@ -87,7 +87,7 @@ public void testConstructor_singleWindow() { @Test public void testAnalyze_singleWindowSingleEdge() { - edge e = makeEdge("f", "A", "B", 100L, 200L); + Edge e = makeEdge("f", "A", "B", 100L, 200L); addEdge(graph, e); TemporalGraph tg = new TemporalGraph(graph); GrowthRateAnalyzer analyzer = new GrowthRateAnalyzer(tg, 1); @@ -101,9 +101,9 @@ public void testAnalyze_singleWindowSingleEdge() { @Test public void testAnalyze_multipleWindows() { // Build a growing graph: edges appear at different times - edge e1 = makeEdge("f", "A", "B", 100L, 500L); - edge e2 = makeEdge("f", "B", "C", 200L, 500L); - edge e3 = makeEdge("f", "C", "D", 300L, 500L); + Edge e1 = makeEdge("f", "A", "B", 100L, 500L); + Edge e2 = makeEdge("f", "B", "C", 200L, 500L); + Edge e3 = makeEdge("f", "C", "D", 300L, 500L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -114,7 +114,7 @@ public void testAnalyze_multipleWindows() { List snapshots = analyzer.analyze(); assertEquals(3, snapshots.size()); - // Each window should have non-negative node/edge counts + // Each window should have non-negative node/Edge counts for (GrowthRateAnalyzer.MetricSnapshot snap : snapshots) { assertTrue(snap.nodeCount >= 0); assertTrue(snap.edgeCount >= 0); @@ -123,8 +123,8 @@ public void testAnalyze_multipleWindows() { @Test public void testAnalyze_snapshotsAreOrdered() { - edge e1 = makeEdge("f", "A", "B", 100L, 400L); - edge e2 = makeEdge("f", "C", "D", 200L, 400L); + Edge e1 = makeEdge("f", "A", "B", 100L, 400L); + Edge e2 = makeEdge("f", "C", "D", 200L, 400L); addEdge(graph, e1); addEdge(graph, e2); @@ -139,12 +139,12 @@ public void testAnalyze_snapshotsAreOrdered() { @Test public void testAnalyze_growingNetwork() { - // Phase 1: 1 edge (t=0..1000) - edge e1 = makeEdge("f", "A", "B", 0L, 1000L); + // Phase 1: 1 Edge (t=0..1000) + Edge e1 = makeEdge("f", "A", "B", 0L, 1000L); addEdge(graph, e1); // Phase 2: 2 more edges (t=500..1000) - edge e2 = makeEdge("f", "B", "C", 500L, 1000L); - edge e3 = makeEdge("f", "C", "A", 500L, 1000L); + Edge e2 = makeEdge("f", "B", "C", 500L, 1000L); + Edge e3 = makeEdge("f", "C", "A", 500L, 1000L); addEdge(graph, e2); addEdge(graph, e3); @@ -162,9 +162,9 @@ public void testAnalyze_growingNetwork() { @Test public void testAnalyze_densityOfCompleteTriangle() { // Triangle: 3 nodes, 3 edges → density = 3/3 = 1.0 - edge e1 = makeEdge("f", "A", "B", 100L, 200L); - edge e2 = makeEdge("f", "B", "C", 100L, 200L); - edge e3 = makeEdge("f", "A", "C", 100L, 200L); + Edge e1 = makeEdge("f", "A", "B", 100L, 200L); + Edge e2 = makeEdge("f", "B", "C", 100L, 200L); + Edge e3 = makeEdge("f", "A", "C", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -179,8 +179,8 @@ public void testAnalyze_densityOfCompleteTriangle() { @Test public void testAnalyze_densityOfPath() { // Path A-B-C: 3 nodes, 2 edges → density = 2/3 ≈ 0.667 - edge e1 = makeEdge("f", "A", "B", 100L, 200L); - edge e2 = makeEdge("f", "B", "C", 100L, 200L); + Edge e1 = makeEdge("f", "A", "B", 100L, 200L); + Edge e2 = makeEdge("f", "B", "C", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); @@ -193,8 +193,8 @@ public void testAnalyze_densityOfPath() { @Test public void testAnalyze_densityOfSingleEdge() { - // 2 nodes, 1 edge → density = 1/1 = 1.0 - edge e1 = makeEdge("f", "A", "B", 100L, 200L); + // 2 nodes, 1 Edge → density = 1/1 = 1.0 + Edge e1 = makeEdge("f", "A", "B", 100L, 200L); addEdge(graph, e1); TemporalGraph tg = new TemporalGraph(graph); @@ -209,9 +209,9 @@ public void testAnalyze_densityOfSingleEdge() { @Test public void testAnalyze_clusteringOfTriangle() { // Complete triangle: all neighbors are connected → clustering = 1.0 - edge e1 = makeEdge("f", "A", "B", 100L, 200L); - edge e2 = makeEdge("f", "B", "C", 100L, 200L); - edge e3 = makeEdge("f", "A", "C", 100L, 200L); + Edge e1 = makeEdge("f", "A", "B", 100L, 200L); + Edge e2 = makeEdge("f", "B", "C", 100L, 200L); + Edge e3 = makeEdge("f", "A", "C", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -228,8 +228,8 @@ public void testAnalyze_clusteringOfPath() { // Path A-B-C: B has 2 neighbors not connected → clustering(B) = 0 // A and C each have 1 neighbor → clustering = 0 // Average = 0 - edge e1 = makeEdge("f", "A", "B", 100L, 200L); - edge e2 = makeEdge("f", "B", "C", 100L, 200L); + Edge e1 = makeEdge("f", "A", "B", 100L, 200L); + Edge e2 = makeEdge("f", "B", "C", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); @@ -244,10 +244,10 @@ public void testAnalyze_clusteringOfPath() { public void testAnalyze_clusteringOfStar() { // Star: A connected to B,C,D,E but no connections among B,C,D,E // clustering(A) = 0 (no triangles), others have degree 1 (skip) - edge e1 = makeEdge("f", "A", "B", 100L, 200L); - edge e2 = makeEdge("f", "A", "C", 100L, 200L); - edge e3 = makeEdge("f", "A", "D", 100L, 200L); - edge e4 = makeEdge("f", "A", "E", 100L, 200L); + Edge e1 = makeEdge("f", "A", "B", 100L, 200L); + Edge e2 = makeEdge("f", "A", "C", 100L, 200L); + Edge e3 = makeEdge("f", "A", "D", 100L, 200L); + Edge e4 = makeEdge("f", "A", "E", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -265,10 +265,10 @@ public void testAnalyze_clusteringOfStar() { @Test public void testEdgeGrowthRate_growingNetwork() { // Edges appearing over time: should have positive growth rate - edge e1 = makeEdge("f", "A", "B", 0L, 1000L); - edge e2 = makeEdge("f", "B", "C", 250L, 1000L); - edge e3 = makeEdge("f", "C", "D", 500L, 1000L); - edge e4 = makeEdge("f", "D", "E", 750L, 1000L); + Edge e1 = makeEdge("f", "A", "B", 0L, 1000L); + Edge e2 = makeEdge("f", "B", "C", 250L, 1000L); + Edge e3 = makeEdge("f", "C", "D", 500L, 1000L); + Edge e4 = makeEdge("f", "D", "E", 750L, 1000L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -284,9 +284,9 @@ public void testEdgeGrowthRate_growingNetwork() { @Test public void testEdgeGrowthRate_shrinkingNetwork() { // Edges disappearing over time: should have negative growth rate - edge e1 = makeEdge("f", "A", "B", 0L, 1000L); - edge e2 = makeEdge("f", "B", "C", 0L, 250L); - edge e3 = makeEdge("f", "C", "D", 0L, 500L); + Edge e1 = makeEdge("f", "A", "B", 0L, 1000L); + Edge e2 = makeEdge("f", "B", "C", 0L, 250L); + Edge e3 = makeEdge("f", "C", "D", 0L, 500L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -301,9 +301,9 @@ public void testEdgeGrowthRate_shrinkingNetwork() { @Test public void testEdgeGrowthRate_stableNetwork() { // All edges active for entire duration: constant count → rate ≈ 0 - edge e1 = makeEdge("f", "A", "B", 0L, 1000L); - edge e2 = makeEdge("f", "B", "C", 0L, 1000L); - edge e3 = makeEdge("f", "C", "A", 0L, 1000L); + Edge e1 = makeEdge("f", "A", "B", 0L, 1000L); + Edge e2 = makeEdge("f", "B", "C", 0L, 1000L); + Edge e3 = makeEdge("f", "C", "A", 0L, 1000L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -318,7 +318,7 @@ public void testEdgeGrowthRate_stableNetwork() { @Test public void testEdgeGrowthRate_singleWindow() { // With only 1 window, can't compute regression → returns 0 - edge e = makeEdge("f", "A", "B", 100L, 200L); + Edge e = makeEdge("f", "A", "B", 100L, 200L); addEdge(graph, e); TemporalGraph tg = new TemporalGraph(graph); @@ -358,8 +358,8 @@ public void testMetricSnapshot_fields() { @Test public void testAnalyze_disconnectedComponents() { // Two disconnected edges at same time - edge e1 = makeEdge("f", "A", "B", 100L, 200L); - edge e2 = makeEdge("f", "C", "D", 100L, 200L); + Edge e1 = makeEdge("f", "A", "B", 100L, 200L); + Edge e2 = makeEdge("f", "C", "D", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); @@ -375,10 +375,10 @@ public void testAnalyze_disconnectedComponents() { @Test public void testAnalyze_edgesWithDifferentTypes() { - // Multiple edge types shouldn't affect metric computation - edge e1 = makeEdge("friendship", "A", "B", 100L, 200L); - edge e2 = makeEdge("work", "B", "C", 100L, 200L); - edge e3 = makeEdge("family", "C", "A", 100L, 200L); + // Multiple Edge types shouldn't affect metric computation + Edge e1 = makeEdge("friendship", "A", "B", 100L, 200L); + Edge e2 = makeEdge("work", "B", "C", 100L, 200L); + Edge e3 = makeEdge("family", "C", "A", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -396,10 +396,10 @@ public void testAnalyze_edgesWithDifferentTypes() { public void testAnalyze_windowWithNoEdges() { // Edge only active in first half of time range // Last windows should have 0 edges - edge e1 = makeEdge("f", "A", "B", 0L, 100L); + Edge e1 = makeEdge("f", "A", "B", 0L, 100L); addEdge(graph, e1); - // Add another edge later to extend time range - edge e2 = makeEdge("f", "C", "D", 900L, 1000L); + // Add another Edge later to extend time range + Edge e2 = makeEdge("f", "C", "D", 900L, 1000L); addEdge(graph, e2); TemporalGraph tg = new TemporalGraph(graph); @@ -426,7 +426,7 @@ public void testAnalyze_k4CompleteGraph() { int id = 0; for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { - edge e = makeEdge("f", verts[i], verts[j], 100L, 200L); + Edge e = makeEdge("f", verts[i], verts[j], 100L, 200L); addEdge(graph, e); id++; } @@ -446,8 +446,8 @@ public void testAnalyze_k4CompleteGraph() { @Test public void testAnalyze_manyWindows() { // Test with many windows (10) - edge e1 = makeEdge("f", "A", "B", 0L, 1000L); - edge e2 = makeEdge("f", "B", "C", 500L, 1000L); + Edge e1 = makeEdge("f", "A", "B", 0L, 1000L); + Edge e2 = makeEdge("f", "B", "C", 500L, 1000L); addEdge(graph, e1); addEdge(graph, e2); @@ -465,7 +465,7 @@ public void testEdgeGrowthRate_linearGrowth() { String v1 = "V" + i; String v2 = "V" + (i + 1); long start = i * 100L; - edge e = makeEdge("f", v1, v2, start, 1000L); + Edge e = makeEdge("f", v1, v2, start, 1000L); addEdge(graph, e); } @@ -478,7 +478,7 @@ public void testEdgeGrowthRate_linearGrowth() { @Test public void testAnalyze_snapshotCountMatchesWindowCount() { - edge e = makeEdge("f", "A", "B", 0L, 100L); + Edge e = makeEdge("f", "A", "B", 0L, 100L); addEdge(graph, e); TemporalGraph tg = new TemporalGraph(graph); @@ -491,11 +491,11 @@ public void testAnalyze_snapshotCountMatchesWindowCount() { @Test public void testEdgeGrowthRate_twoWindows() { - // 2 windows: window 1 has 1 edge, window 2 has 3 edges + // 2 windows: window 1 has 1 Edge, window 2 has 3 edges // slope = (3-1)/1 = 2.0 - edge e1 = makeEdge("f", "A", "B", 0L, 200L); - edge e2 = makeEdge("f", "B", "C", 100L, 200L); - edge e3 = makeEdge("f", "C", "D", 100L, 200L); + Edge e1 = makeEdge("f", "A", "B", 0L, 200L); + Edge e2 = makeEdge("f", "B", "C", 100L, 200L); + Edge e3 = makeEdge("f", "C", "D", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -510,8 +510,8 @@ public void testEdgeGrowthRate_twoWindows() { @Test public void testAnalyze_densityWithEmptyWindow() { // Windows with 0 or 1 nodes should have density 0 - edge e1 = makeEdge("f", "A", "B", 0L, 50L); - edge e2 = makeEdge("f", "C", "D", 950L, 1000L); + Edge e1 = makeEdge("f", "A", "B", 0L, 50L); + Edge e2 = makeEdge("f", "C", "D", 950L, 1000L); addEdge(graph, e1); addEdge(graph, e2); @@ -530,10 +530,10 @@ public void testAnalyze_densityWithEmptyWindow() { public void testAnalyze_clusteringWithPartialTriangles() { // Square: A-B-C-D-A (4 nodes, 4 edges, no diagonals) // Each node has degree 2, neighbors not connected → clustering = 0 - edge e1 = makeEdge("f", "A", "B", 100L, 200L); - edge e2 = makeEdge("f", "B", "C", 100L, 200L); - edge e3 = makeEdge("f", "C", "D", 100L, 200L); - edge e4 = makeEdge("f", "D", "A", 100L, 200L); + Edge e1 = makeEdge("f", "A", "B", 100L, 200L); + Edge e2 = makeEdge("f", "B", "C", 100L, 200L); + Edge e3 = makeEdge("f", "C", "D", 100L, 200L); + Edge e4 = makeEdge("f", "D", "A", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); @@ -555,11 +555,11 @@ public void testAnalyze_clusteringWithOneDiagonal() { // C: neighbors A,B,D; pairs: (A,B)=yes, (A,D)=yes, (B,D)=no → 2/3 // D: neighbors A,C; pair (A,C)=yes → 1/1 = 1.0 // Average = (2/3 + 1 + 2/3 + 1) / 4 = (10/3) / 4 ≈ 0.833 - edge e1 = makeEdge("f", "A", "B", 100L, 200L); - edge e2 = makeEdge("f", "B", "C", 100L, 200L); - edge e3 = makeEdge("f", "C", "D", 100L, 200L); - edge e4 = makeEdge("f", "D", "A", 100L, 200L); - edge e5 = makeEdge("f", "A", "C", 100L, 200L); + Edge e1 = makeEdge("f", "A", "B", 100L, 200L); + Edge e2 = makeEdge("f", "B", "C", 100L, 200L); + Edge e3 = makeEdge("f", "C", "D", 100L, 200L); + Edge e4 = makeEdge("f", "D", "A", 100L, 200L); + Edge e5 = makeEdge("f", "A", "C", 100L, 200L); addEdge(graph, e1); addEdge(graph, e2); addEdge(graph, e3); diff --git a/Gvisual/test/gvisual/HamiltonianAnalyzerTest.java b/Gvisual/test/gvisual/HamiltonianAnalyzerTest.java index 1845307..60891dd 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 @@ -25,8 +25,8 @@ public void setUp() { edgeId = 0; } - private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + private Edge addEdge(String v1, String v2) { + Edge e = new Edge("f", v1, v2); e.setWeight(1.0f); e.setLabel("e" + (edgeId++)); if (!graph.containsVertex(v1)) graph.addVertex(v1); @@ -301,7 +301,7 @@ public void testPathBetweenImpossible() { buildPath("A", "B", "C", "D"); List path = analyzer.findHamiltonianPath(graph, "B", "C"); // B-A-...no way to visit all, or B-C-D-...can't reach A from D without going through visited - // Actually: B→A then stuck (A has only B neighbor), so B→C→D then need A, D→A? no edge + // Actually: B→A then stuck (A has only B neighbor), so B→C→D then need A, D→A? no Edge // So this should be null assertNull(path); } diff --git a/Gvisual/test/gvisual/HierarchicalLayoutTest.java b/Gvisual/test/gvisual/HierarchicalLayoutTest.java index 0782931..5acd211 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,11 +531,11 @@ 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) { - // duplicate edge, skip + // duplicate Edge, skip } } } diff --git a/Gvisual/test/gvisual/IndependentSetAnalyzerTest.java b/Gvisual/test/gvisual/IndependentSetAnalyzerTest.java index eabe2a1..13760aa 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() { @@ -34,52 +34,52 @@ public void setUp() { singleVertex = new UndirectedSparseGraph<>(); singleVertex.addVertex("A"); - // Single edge + // Single Edge 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 @@ -574,12 +574,12 @@ public void testMaxCliqueOnTriangle() { public void testMaxCliqueOnPath4() { IndependentSetAnalyzer a = new IndependentSetAnalyzer(path4); Set clique = a.maximumCliqueViaComplement(); - assertEquals(2, clique.size()); // max clique in P4 = any edge + assertEquals(2, clique.size()); // max clique in P4 = any Edge } @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..d0fee73 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..78d666a 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..908d1ac 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..4c5fb47 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); + private Edge addEdge(String v1, String 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); @@ -94,7 +94,7 @@ public void testAllIsolatedVertices() { } // ═══════════════════════════════════════ - // Simple edge (2 vertices) + // Simple Edge (2 vertices) // ═══════════════════════════════════════ @Test diff --git a/Gvisual/test/gvisual/KTrussAnalyzerTest.java b/Gvisual/test/gvisual/KTrussAnalyzerTest.java index 69e84ab..120c2a3 100644 --- a/Gvisual/test/gvisual/KTrussAnalyzerTest.java +++ b/Gvisual/test/gvisual/KTrussAnalyzerTest.java @@ -15,15 +15,15 @@ */ public class KTrussAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { graph = new UndirectedSparseGraph<>(); } - private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + private Edge addEdge(String v1, String v2) { + Edge e = new Edge("f", v1, v2); e.setWeight(1.0f); graph.addEdge(e, v1, v2); return e; @@ -40,18 +40,18 @@ public void testEmptyGraph() { public void testSingleEdge_noTriangle() { addEdge("A", "B"); KTrussAnalyzer analyzer = new KTrussAnalyzer(graph); - // An edge with no triangles has truss number 2 + // An Edge with no triangles has truss number 2 assertEquals(2, analyzer.getMaxTrussNumber()); } @Test public void testTriangle() { - edge ab = addEdge("A", "B"); - edge bc = addEdge("B", "C"); - edge ac = addEdge("A", "C"); + Edge ab = addEdge("A", "B"); + Edge bc = addEdge("B", "C"); + Edge ac = addEdge("A", "C"); KTrussAnalyzer analyzer = new KTrussAnalyzer(graph); - // A triangle: each edge has 1 triangle support → 3-truss + // A triangle: each Edge has 1 triangle support → 3-truss assertTrue(analyzer.getMaxTrussNumber() >= 2); assertEquals(1, analyzer.getTriangleSupport(ab)); assertEquals(1, analyzer.getTriangleSupport(bc)); @@ -60,7 +60,7 @@ public void testTriangle() { @Test public void testClique4() { - // K4: each edge participates in 2 triangles → 4-truss + // K4: each Edge participates in 2 triangles → 4-truss addEdge("A", "B"); addEdge("A", "C"); addEdge("A", "D"); @@ -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..be6720a 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); @@ -147,7 +147,7 @@ public void testLaplacian_fromAdjMatrix() { @Test public void testSubgraphLaplacian_subset() { addEdge("A", "B"); addEdge("B", "C"); addEdge("C", "D"); - // Subgraph on {B, C}: only the B-C edge counts + // Subgraph on {B, C}: only the B-C Edge counts List sub = Arrays.asList("B", "C"); double[][] L = LaplacianBuilder.buildSubgraphLaplacian(graph, sub); assertEquals(1.0, L[0][0], 1e-10); diff --git a/Gvisual/test/gvisual/LineGraphAnalyzerTest.java b/Gvisual/test/gvisual/LineGraphAnalyzerTest.java index 70497f4..8edecef 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,14 +261,14 @@ 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++) assertFalse(lg.isNeighbor(ml.get(i), ml.get(j))); } - // ── Vertex edge-cliques ───────────────────────────────────────── + // ── Vertex Edge-cliques ───────────────────────────────────────── @Test public void testCliquesK4Size() { @@ -304,7 +304,7 @@ public void testNbrsPath3() { for (Set s : n.values()) assertEquals(1, s.size()); } - // ── Most central edge ─────────────────────────────────────────── + // ── Most central Edge ─────────────────────────────────────────── @Test public void testCentralEmpty() { assertNull(new LineGraphAnalyzer(emptyGraph()).mostCentralEdge()); } diff --git a/Gvisual/test/gvisual/LinkPredictionAnalyzerTest.java b/Gvisual/test/gvisual/LinkPredictionAnalyzerTest.java index 2d9edf0..b75f605 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,13 +157,13 @@ 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 = analyzer.predict(LinkPredictionAnalyzer.Method.COMMON_NEIGHBORS, 10); - // 1 edge out of 3 possible = 33.3% + // 1 Edge out of 3 possible = 33.3% assertEquals(1.0 / 3.0, result.getDensity(), 0.001); } @@ -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 = @@ -326,7 +326,7 @@ public void testResultsSortedByScoreDescending() { } } - // ── Jaccard edge cases ───────────────────────────────────── + // ── Jaccard Edge cases ───────────────────────────────────── @Test public void testJaccardWithDifferentSizedNeighborhoods() { @@ -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..f485038 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..5974824 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..6f13f2b 100644 --- a/Gvisual/test/gvisual/MetricDimensionAnalyzerTest.java +++ b/Gvisual/test/gvisual/MetricDimensionAnalyzerTest.java @@ -9,47 +9,47 @@ /** * Tests for MetricDimensionAnalyzer — 55 tests covering exact and greedy * metric dimension, distance matrices, twin detection, resolving sets, - * metric representation, bounds, and edge cases. + * metric representation, bounds, and Edge cases. */ 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..06c7723 100644 --- a/Gvisual/test/gvisual/MinimumSpanningTreeTest.java +++ b/Gvisual/test/gvisual/MinimumSpanningTreeTest.java @@ -10,15 +10,15 @@ /** * Tests for MinimumSpanningTree — Kruskal's algorithm with Union-Find, - * MST computation, component analysis, and edge type distribution. + * MST computation, component analysis, and Edge type distribution. */ 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"); @@ -546,13 +546,13 @@ public void testLargerGraph() { // 4 3 5 2 // | / | / // D--7--E--8--F - edge[] edges = { + Edge[] edges = { makeEdge("f", "A", "B", 1), makeEdge("c", "A", "D", 4), makeEdge("f", "B", "D", 3), makeEdge("s", "B", "E", 5), 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); @@ -683,16 +683,16 @@ public void testComponentsUnmodifiable() { } // ========================================== - // Mixed edge types + // Mixed Edge types // ========================================== @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"); @@ -705,7 +705,7 @@ public void testMixedEdgeTypes() { assertEquals(4, result.getEdgeCount()); assertEquals(10.0f, result.getTotalWeight(), 0.001f); // 1+2+3+4 - // sg edge (weight 10) should NOT be in MST + // sg Edge (weight 10) should NOT be in MST assertFalse(result.getEdges().contains(e5)); Map dist = result.getEdgeTypeDistribution(); @@ -768,8 +768,8 @@ public void testUnionFindSelfUnion() { // Helper // ========================================== - private edge makeEdge(String type, String v1, String v2, float weight) { - edge e = new edge(type, v1, v2); + private Edge makeEdge(String type, String v1, String v2, float weight) { + 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..0bf5cae 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); + private Edge addEdge(String v1, String 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..7fcdb26 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); + private Edge addEdge(String v1, String v2, float weight) { + Edge e = new Edge("f", v1, v2); e.setWeight(weight); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); @@ -34,7 +34,7 @@ private edge addEdge(String v1, String v2, float weight) { return e; } - private edge addEdge(String v1, String v2) { + private Edge addEdge(String v1, String v2) { return addEdge(v1, v2, 1.0f); } @@ -110,7 +110,7 @@ public void testSingleEdge() { public void testSingleEdgeReverse() { addEdge("A", "B", 5.0f); NetworkFlowAnalyzer nfa = new NetworkFlowAnalyzer(graph); - // Flow from B to A through undirected edge + // Flow from B to A through undirected Edge double flow = nfa.compute("B", "A"); assertEquals(5.0, flow, 1e-9); } @@ -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"); @@ -258,7 +258,7 @@ public void testGetFlowOnNonexistentEdge() { addEdge("A", "B", 5.0f); NetworkFlowAnalyzer nfa = new NetworkFlowAnalyzer(graph); nfa.compute("A", "B"); - // No edge X->Y + // No Edge X->Y assertEquals(0.0, nfa.getFlowOnEdge("X", "Y"), 1e-9); } @@ -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 @@ -583,7 +583,7 @@ public void testStarGraph() { addEdge("H", "C", 1.0f); addEdge("H", "D", 4.0f); NetworkFlowAnalyzer nfa = new NetworkFlowAnalyzer(graph); - // Flow from H to D: limited to H-D edge (4.0) + // Flow from H to D: limited to H-D Edge (4.0) double flow = nfa.compute("H", "D"); assertEquals(4.0, flow, 1e-9); } diff --git a/Gvisual/test/gvisual/NetworkReportGeneratorTest.java b/Gvisual/test/gvisual/NetworkReportGeneratorTest.java index 409f65c..4475a8d 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) { + 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; @@ -64,7 +64,7 @@ public void testGenerateWithNodes() { assertTrue(html.contains("Test Network")); assertTrue(html.contains("4")); // node count - assertTrue(html.contains("3")); // edge count + assertTrue(html.contains("3")); // Edge count assertTrue(html.contains("Friend")); assertTrue(html.contains("Classmate")); } @@ -80,7 +80,7 @@ public void testContainsSvgCharts() { assertTrue("Should contain SVG elements", html.contains("Covers: classification pipeline, role assignment rules, adaptive thresholds, - * report generation, edge cases (empty graph, single node, disconnected nodes, + * report generation, Edge cases (empty graph, single node, disconnected nodes, * complete graph), and all structural role archetypes.

      * * @author zalenix @@ -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..e7e6a68 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); + private Edge addEdge(String type, String v1, String v2, float weight) { + Edge e = new Edge(type, v1, v2); e.setWeight(weight); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); @@ -76,7 +76,7 @@ public void testEmptyGraphTopology() { assertEquals("Trivial", analyzer.classifyTopology()); } - // --- Single edge graph --- + // --- Single Edge graph --- @Test public void testSingleEdge() { @@ -663,7 +663,7 @@ public void testMixedEdgeTypes() { NodeCentralityAnalyzer analyzer = new NodeCentralityAnalyzer(graph); analyzer.compute(); - // Should work regardless of edge types + // Should work regardless of Edge types assertEquals(4, analyzer.getRankedResults().size()); for (NodeCentralityAnalyzer.CentralityResult r : analyzer.getRankedResults()) { assertTrue(r.getDegreeCentrality() >= 0); diff --git a/Gvisual/test/gvisual/NodeSimilarityAnalyzerTest.java b/Gvisual/test/gvisual/NodeSimilarityAnalyzerTest.java index bce3cd6..83cb8e2 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..463d1fd 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); + private Edge addEdge(String type, String v1, String v2, float weight) { + Edge e = new Edge(type, v1, v2); e.setWeight(weight); if (!graph.containsVertex(v1)) graph.addVertex(v1); if (!graph.containsVertex(v2)) graph.addVertex(v2); @@ -33,7 +33,7 @@ private edge addEdge(String type, String v1, String v2, float weight) { return e; } - private edge addEdge(String v1, String v2) { + private Edge addEdge(String v1, String v2) { return addEdge("f", v1, v2, 1.0f); } diff --git a/Gvisual/test/gvisual/PlanarGraphAnalyzerTest.java b/Gvisual/test/gvisual/PlanarGraphAnalyzerTest.java index cd9db0d..0f3c330 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,11 +265,11 @@ public void testSquareFaces() { @Test public void testSingleEdgeFaces() { - Graph g = newGraph(); + Graph g = newGraph(); addEdge(g, "A", "B"); List faces = PlanarGraphAnalyzer.enumerateFaces(g); assertNotNull(faces); - // Single edge: 1 face (the entire plane) + // Single Edge: 1 face (the entire plane) assertTrue(faces.size() >= 1); } @@ -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..3e7e1eb 100644 --- a/Gvisual/test/gvisual/RandomWalkAnalyzerTest.java +++ b/Gvisual/test/gvisual/RandomWalkAnalyzerTest.java @@ -14,15 +14,15 @@ */ public class RandomWalkAnalyzerTest { - private Graph graph; + private Graph graph; @Before public void setUp() { graph = new UndirectedSparseGraph<>(); } - private edge addEdge(String v1, String v2) { - edge e = new edge("f", v1, v2); + private Edge addEdge(String v1, String 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..5bbed46 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); } } } @@ -161,7 +161,7 @@ public void testMembersSortedByDegree() { assertTrue(members.get(2).startsWith("Hub")); } - // ── Internal edge fraction ──────────────────────────────────────────── + // ── Internal Edge fraction ──────────────────────────────────────────── @Test public void testInternalEdgeFractionComplete() { @@ -311,22 +311,22 @@ 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 + assertEquals(1.0, phi, 0.001); // 2 nodes, 1 Edge, φ = 2*1/(2*1) = 1 } @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..9ad9b01 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); + private Edge makeEdge(String type, String v1, String v2, float weight) { + Edge e = new Edge(type, v1, v2); e.setWeight(weight); return e; } @@ -60,7 +60,7 @@ public void testSameSourceAndTarget() { public void testDirectConnection() { graph.addVertex("A"); graph.addVertex("B"); - edge e = makeEdge("f", "A", "B", 5.0f); + Edge e = makeEdge("f", "A", "B", 5.0f); graph.addEdge(e, "A", "B"); ShortestPathFinder finder = new ShortestPathFinder(graph); @@ -120,7 +120,7 @@ public void testShortestHopsNotWeightOptimal() { public void testNoPathExists() { graph.addVertex("A"); graph.addVertex("B"); - // No edge between them + // No Edge between them ShortestPathFinder finder = new ShortestPathFinder(graph); ShortestPathFinder.PathResult result = finder.findShortestByHops("A", "B"); @@ -286,7 +286,7 @@ public void testAreConnectedSelf() { public void testPathResultToString() { graph.addVertex("A"); graph.addVertex("B"); - edge e = makeEdge("f", "A", "B", 5.0f); + Edge e = makeEdge("f", "A", "B", 5.0f); graph.addEdge(e, "A", "B"); ShortestPathFinder finder = new ShortestPathFinder(graph); @@ -345,7 +345,7 @@ public void testPathAcrossEdgeTypes() { assertEquals(3, result.getHopCount()); assertEquals(10.0, result.getTotalWeight(), 0.001); - // Check edge types + // Check Edge types assertEquals("f", result.getEdges().get(0).getType()); assertEquals("c", result.getEdges().get(1).getType()); assertEquals("s", result.getEdges().get(2).getType()); @@ -393,7 +393,7 @@ public void testStarTopology() { assertEquals("H", result.getVertices().get(1)); } - // ── Zero-weight edge bug fix (previously clamped to 0.001) ──── + // ── Zero-weight Edge bug fix (previously clamped to 0.001) ──── @Test public void dijkstraZeroWeightEdge_reportsZeroTotalWeight() { @@ -455,7 +455,7 @@ public void dijkstraNegativeWeight_throws() { @Test public void dijkstraZeroWeightSelfConsistentResult() { - // Ensure totalWeight in result matches actual edge weights + // Ensure totalWeight in result matches actual Edge weights // (was inconsistent: Dijkstra used 0.001 but result used true weight) graph.addEdge(makeEdge("e", "A", "B", 0.0f), "A", "B"); graph.addEdge(makeEdge("e", "B", "C", 1.0f), "B", "C"); diff --git a/Gvisual/test/gvisual/SignedGraphAnalyzerTest.java b/Gvisual/test/gvisual/SignedGraphAnalyzerTest.java index 5ac7a39..75bccfb 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); + private Edge makeEdge(String v1, String v2, float weight) { + 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); + private Edge makeLabelEdge(String v1, String v2, String label) { + Edge e = new Edge("e", v1, v2); e.setLabel(label); return e; } @@ -115,7 +115,7 @@ public void testNullGraph() { @Test public void testIsNegativeByWeight() { - edge e = makeEdge("A","B",-1); + Edge e = makeEdge("A","B",-1); SignedGraphAnalyzer a = new SignedGraphAnalyzer(emptyGraph); assertTrue(a.isNegative(e)); assertFalse(a.isPositive(e)); @@ -123,7 +123,7 @@ public void testIsNegativeByWeight() { @Test public void testIsPositiveByWeight() { - edge e = makeEdge("A","B",1); + Edge e = makeEdge("A","B",1); SignedGraphAnalyzer a = new SignedGraphAnalyzer(emptyGraph); assertFalse(a.isNegative(e)); assertTrue(a.isPositive(e)); @@ -131,21 +131,21 @@ public void testIsPositiveByWeight() { @Test public void testIsNegativeByLabel() { - edge e = makeLabelEdge("A","B","-"); + Edge e = makeLabelEdge("A","B","-"); SignedGraphAnalyzer a = new SignedGraphAnalyzer(emptyGraph); assertTrue(a.isNegative(e)); } @Test public void testIsNegativeByLabelWord() { - edge e = makeLabelEdge("A","B","negative"); + Edge e = makeLabelEdge("A","B","negative"); SignedGraphAnalyzer a = new SignedGraphAnalyzer(emptyGraph); assertTrue(a.isNegative(e)); } @Test public void testZeroWeightIsPositive() { - edge e = makeEdge("A","B",0); + Edge e = makeEdge("A","B",0); e.setLabel(null); SignedGraphAnalyzer a = new SignedGraphAnalyzer(emptyGraph); assertTrue(a.isPositive(e)); @@ -352,7 +352,7 @@ public void testWeaklyBalancedAllNegative() { @Test public void testWeaklyUnbalancedPPN() { - // ++- triangle: NOT weakly balanced (negative edge within positive component) + // ++- triangle: NOT weakly balanced (negative Edge within positive component) assertFalse(new SignedGraphAnalyzer(unbalanced).isWeaklyBalanced()); } @@ -423,13 +423,13 @@ public void testFrustrationEmpty() { @Test public void testFrustrationUnbalanced() { - // ++- triangle: need to flip 1 edge + // ++- triangle: need to flip 1 Edge assertEquals(1, new SignedGraphAnalyzer(unbalanced).frustrationIndex()); } @Test public void testFrustrationAllNegative() { - // --- triangle: need to flip 1 edge to get +-- + // --- triangle: need to flip 1 Edge to get +-- assertEquals(1, new SignedGraphAnalyzer(allNegative).frustrationIndex()); } @@ -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..ee8506d 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..a050f2a 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); + private Edge addEdge(String v1, String 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; @@ -122,7 +122,7 @@ public void testIdempotent() { } // ═══════════════════════════════════════════════════════════════ - // Single edge (K2) + // Single Edge (K2) // ═══════════════════════════════════════════════════════════════ @Test diff --git a/Gvisual/test/gvisual/SteinerTreeAnalyzerTest.java b/Gvisual/test/gvisual/SteinerTreeAnalyzerTest.java index 9bedb05..57ce7c9 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,18 +279,18 @@ 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"))); assertTrue(r.exact); } - // ── Bottleneck edge ─────────────────────────────────────────── + // ── Bottleneck Edge ─────────────────────────────────────────── @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..b8c95a9 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); @@ -89,11 +89,11 @@ public void testSingleVertex() { assertTrue(result.getComponents().get(0).isTrivial()); } - // ── Two vertices, one edge ────────────────────────────────── + // ── Two vertices, one Edge ────────────────────────────────── @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[][]{ + // Chain: A->B->C (3 SCCs, 1 source, 1 sink) => need max(1,1) = 1 Edge + 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,9 +351,9 @@ 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 + {"D", "A"} // back Edge creates one big SCC }); assertBothAlgorithmsAgree(g, 1); } @@ -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 @@ -416,7 +416,7 @@ public void testParallelBridgeEdges() { assertEquals(2, result.getComponentCount()); assertEquals(2, result.getBridgeEdges().size()); - // Condensation should have only 1 edge (deduplicated) + // Condensation should have only 1 Edge (deduplicated) assertEquals(1, result.getCondensation().getEdgeCount()); } @@ -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..0272e8b 100644 --- a/Gvisual/test/gvisual/SubgraphExtractorTest.java +++ b/Gvisual/test/gvisual/SubgraphExtractorTest.java @@ -16,25 +16,25 @@ * Unit tests for {@link SubgraphExtractor}. * * Tests the fluent builder API for subgraph extraction including - * edge type filtering, weight filtering, degree filtering, k-hop + * Edge type filtering, weight filtering, degree filtering, k-hop * neighborhoods, node whitelisting, time windows, connected-only * mode, CSV export, and result statistics. */ 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); + /** 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); e.setWeight(weight); return e; } - private edge makeTimedEdge(String type, String v1, String v2, float weight, + private Edge makeTimedEdge(String type, String v1, String v2, float weight, long start, long end) { - edge e = makeEdge(type, v1, v2, weight); + Edge e = makeEdge(type, v1, v2, weight); e.setTimestamp(start); e.setEndTimestamp(end); return e; @@ -51,17 +51,17 @@ public void setUp() { graph = new UndirectedSparseGraph<>(); edges = new ArrayList<>(); - edge e1 = makeEdge("f", "A", "B", 3.0f); - edge e2 = makeEdge("c", "B", "C", 1.0f); - edge e3 = makeEdge("f", "C", "D", 5.0f); - edge e4 = makeEdge("s", "D", "E", 2.0f); - edge e5 = makeEdge("c", "A", "C", 4.0f); - edge e6 = makeEdge("f", "B", "D", 2.0f); + Edge e1 = makeEdge("f", "A", "B", 3.0f); + Edge e2 = makeEdge("c", "B", "C", 1.0f); + Edge e3 = makeEdge("f", "C", "D", 5.0f); + Edge e4 = makeEdge("s", "D", "E", 2.0f); + Edge e5 = makeEdge("c", "A", "C", 4.0f); + Edge e6 = makeEdge("f", "B", "D", 2.0f); 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); } @@ -99,8 +99,8 @@ public void testFilterByEdgeTypeKeepsOnlyMatchingEdges() { .extract(); // 3 "f" edges: A-B, C-D, B-D assertEquals(3, result.getEdgeCount()); - // Nodes involved: A, B, C, D (all have at least one "f" edge) - // E is included as vertex (not connectedOnly) but has no f-edge + // Nodes involved: A, B, C, D (all have at least one "f" Edge) + // E is included as vertex (not connectedOnly) but has no f-Edge assertTrue(result.getGraph().containsVertex("A")); assertTrue(result.getGraph().containsVertex("B")); } @@ -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) @@ -265,7 +265,7 @@ public void testConnectedOnlyRemovesIsolatedNodes() { .connectedOnly(true) .extract(); // f-edges: A-B, C-D, B-D → nodes with edges: A,B,C,D - // E has no f-edge → removed + // E has no f-Edge → removed assertFalse(result.getGraph().containsVertex("E")); assertEquals(4, result.getNodeCount()); } @@ -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..cd85334 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()); @@ -233,11 +233,11 @@ public void testNoSquareInTriangle() { @Test public void testDiamondInK4() { // K4 has 4 nodes, 6 edges. Diamond has 4 nodes, 5 edges. - // Each diamond is K4 minus one edge. 6 possible removals = 6 diamonds. + // Each diamond is K4 minus one Edge. 6 possible removals = 6 diamonds. // 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..95ff786 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"); } @@ -69,7 +69,7 @@ public void svgContainsEdgeLines() { String svg = exporter.exportToString(); // Should contain line elements for edges assertTrue(svg.contains(" 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("