Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
*/
public class AdjacencyMatrixHeatmap extends JPanel {

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

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

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

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

Expand Down
32 changes: 16 additions & 16 deletions Gvisual/src/gvisual/ArticulationPointAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
*/
public class ArticulationPointAnalyzer {

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

/**
* Create a new analyzer for the given graph.
*
* @param graph the JUNG graph to analyze (must not be null)
* @throws IllegalArgumentException if graph is null
*/
public ArticulationPointAnalyzer(Graph<String, edge> graph) {
public ArticulationPointAnalyzer(Graph<String, Edge> graph) {
if (graph == null) {
throw new IllegalArgumentException("Graph must not be null");
}
Expand All @@ -46,13 +46,13 @@ public ArticulationPointAnalyzer(Graph<String, edge> graph) {
* A bridge (cut edge) whose removal disconnects the graph.
*/
public static class Bridge {
private final edge bridgeEdge;
private final Edge bridgeEdge;
private final String endpoint1;
private final String endpoint2;
private final int componentSizeA;
private final int componentSizeB;

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

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

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

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

// Bridge: low[v] > disc[u]
if (low.get(v) > disc.get(u)) {
edge bridgeEdge = findEdge(u, v);
Edge bridgeEdge = findEdge(u, v);
if (bridgeEdge != null) {
bridges.add(bridgeEdge);
}
Expand All @@ -329,8 +329,8 @@ private void dfs(String u,
/**
* Find the edge connecting two vertices.
*/
private edge findEdge(String u, String v) {
for (edge e : graph.getIncidentEdges(u)) {
private Edge findEdge(String u, String v) {
for (Edge e : graph.getIncidentEdges(u)) {
String v1 = e.getVertex1();
String v2 = e.getVertex2();
// Also check via JUNG endpoints since vertex1/vertex2 may be null
Expand All @@ -348,7 +348,7 @@ private edge findEdge(String u, String v) {
/**
* Find endpoints of an edge via the graph when vertex1/vertex2 may be null.
*/
private String[] findEndpoints(edge e) {
private String[] findEndpoints(Edge e) {
Collection<String> endpoints = graph.getEndpoints(e);
if (endpoints != null && endpoints.size() == 2) {
Iterator<String> it = endpoints.iterator();
Expand Down Expand Up @@ -396,7 +396,7 @@ private int countBiconnectedComponents(String vertex) {
* Estimate the sizes of the two components that would result from
* removing a bridge edge.
*/
private int[] estimateComponentSizes(String v1, String v2, edge bridgeEdge) {
private int[] estimateComponentSizes(String v1, String v2, Edge bridgeEdge) {
// BFS from v1, excluding the bridge edge
Set<String> comp1 = bfsExcludingEdge(v1, bridgeEdge);
Set<String> comp2 = bfsExcludingEdge(v2, bridgeEdge);
Expand All @@ -406,15 +406,15 @@ private int[] estimateComponentSizes(String v1, String v2, edge bridgeEdge) {
/**
* BFS from a start vertex, excluding a specific edge.
*/
private Set<String> bfsExcludingEdge(String start, edge excluded) {
private Set<String> bfsExcludingEdge(String start, Edge excluded) {
Set<String> visited = new HashSet<String>();
Queue<String> queue = new LinkedList<String>();
queue.add(start);
visited.add(start);

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

private final Graph<String, edge> graph;
private final Graph<String, Edge> graph;
private Map<String, Integer> coloring;
private boolean bipartite;
private boolean computed;
Expand All @@ -45,7 +45,7 @@ public class BipartiteAnalyzer {
* @param graph the JUNG graph to analyze
* @throws IllegalArgumentException if graph is null
*/
public BipartiteAnalyzer(Graph<String, edge> graph) {
public BipartiteAnalyzer(Graph<String, Edge> graph) {
if (graph == null) {
throw new IllegalArgumentException("Graph must not be null");
}
Expand Down
26 changes: 13 additions & 13 deletions Gvisual/src/gvisual/ChordalGraphAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public String toTextReport() {
* @param graph the graph
* @return MCS ordering (last eliminated first)
*/
public static List<String> maximumCardinalitySearch(Graph<String, edge> graph) {
public static List<String> maximumCardinalitySearch(Graph<String, Edge> graph) {
if (graph == null) return Collections.emptyList();
Collection<String> vertices = graph.getVertices();
if (vertices == null || vertices.isEmpty()) return Collections.emptyList();
Expand Down Expand Up @@ -247,7 +247,7 @@ public static List<String> maximumCardinalitySearch(Graph<String, edge> graph) {
* @param graph the graph
* @return ChordalityResult with PEO if chordal, or a chordless cycle if not
*/
public static ChordalityResult testChordality(Graph<String, edge> graph) {
public static ChordalityResult testChordality(Graph<String, Edge> graph) {
if (graph == null || graph.getVertexCount() == 0) {
return new ChordalityResult(true, Collections.<String>emptyList(), null);
}
Expand Down Expand Up @@ -349,7 +349,7 @@ private static List<String> findChordlessCycle(Map<String, Set<String>> adj,
* @param graph the graph
* @return coloring result
*/
public static ColoringResult optimalColoring(Graph<String, edge> graph) {
public static ColoringResult optimalColoring(Graph<String, Edge> graph) {
if (graph == null || graph.getVertexCount() == 0) {
return new ColoringResult(Collections.<String, Integer>emptyMap(), 0);
}
Expand Down Expand Up @@ -396,7 +396,7 @@ public static ColoringResult optimalColoring(Graph<String, edge> graph) {
* @param graph the graph
* @return vertices of a maximum clique
*/
public static Set<String> maximumClique(Graph<String, edge> graph) {
public static Set<String> maximumClique(Graph<String, Edge> graph) {
if (graph == null || graph.getVertexCount() == 0) {
return Collections.emptySet();
}
Expand Down Expand Up @@ -433,7 +433,7 @@ public static Set<String> maximumClique(Graph<String, edge> graph) {
return best;
}

private static Set<String> findMaxCliqueGreedy(Graph<String, edge> graph) {
private static Set<String> findMaxCliqueGreedy(Graph<String, Edge> graph) {
Map<String, Set<String>> adj = GraphUtils.buildAdjacencyMap(graph);
// Sort vertices by degree descending
List<String> sorted = new ArrayList<>(graph.getVertices());
Expand Down Expand Up @@ -467,7 +467,7 @@ private static Set<String> findMaxCliqueGreedy(Graph<String, edge> graph) {
* @param graph the graph
* @return list of maximal cliques
*/
public static List<Set<String>> allMaximalCliques(Graph<String, edge> graph) {
public static List<Set<String>> allMaximalCliques(Graph<String, Edge> graph) {
if (graph == null || graph.getVertexCount() == 0) {
return Collections.emptyList();
}
Expand Down Expand Up @@ -528,7 +528,7 @@ public static List<Set<String>> allMaximalCliques(Graph<String, edge> graph) {
* @param graph the graph
* @return list of clique tree nodes with neighbor relationships
*/
public static List<CliqueTreeNode> buildCliqueTree(Graph<String, edge> graph) {
public static List<CliqueTreeNode> buildCliqueTree(Graph<String, Edge> graph) {
List<Set<String>> cliques = allMaximalCliques(graph);
if (cliques.isEmpty()) return Collections.emptyList();

Expand Down Expand Up @@ -597,7 +597,7 @@ private static int intersectionSize(Set<String> a, Set<String> b) {
* @param graph the graph
* @return fill-in result with list of edges to add
*/
public static FillInResult computeFillIn(Graph<String, edge> graph) {
public static FillInResult computeFillIn(Graph<String, Edge> graph) {
if (graph == null || graph.getVertexCount() == 0) {
return new FillInResult(Collections.<String[]>emptyList());
}
Expand Down Expand Up @@ -633,7 +633,7 @@ public static FillInResult computeFillIn(Graph<String, edge> graph) {
String u = laterNeighbors.get(a);
String w = laterNeighbors.get(b);
if (!augmented.get(u).contains(w)) {
// Add fill edge
// Add fill Edge
augmented.get(u).add(w);
augmented.get(w).add(u);
String first = u.compareTo(w) < 0 ? u : w;
Expand All @@ -656,7 +656,7 @@ public static FillInResult computeFillIn(Graph<String, edge> graph) {
* @param graph the graph
* @return list of minimal separators
*/
public static List<Set<String>> minimalSeparators(Graph<String, edge> graph) {
public static List<Set<String>> minimalSeparators(Graph<String, Edge> graph) {
List<Set<String>> cliques = allMaximalCliques(graph);
List<CliqueTreeNode> tree = buildCliqueTree(graph);
if (tree.size() <= 1) return Collections.emptyList();
Expand Down Expand Up @@ -684,7 +684,7 @@ public static List<Set<String>> minimalSeparators(Graph<String, edge> graph) {
* @param graph the graph
* @return treewidth, or -1 for empty graph
*/
public static int treewidth(Graph<String, edge> graph) {
public static int treewidth(Graph<String, Edge> graph) {
Set<String> mc = maximumClique(graph);
return mc.isEmpty() ? -1 : mc.size() - 1;
}
Expand All @@ -698,7 +698,7 @@ public static int treewidth(Graph<String, edge> graph) {
* @param order elimination order
* @return list of cliques formed at each elimination step
*/
public static List<Set<String>> eliminationCliques(Graph<String, edge> graph,
public static List<Set<String>> eliminationCliques(Graph<String, Edge> graph,
List<String> order) {
if (graph == null || order == null) return Collections.emptyList();

Expand Down Expand Up @@ -745,7 +745,7 @@ public static List<Set<String>> eliminationCliques(Graph<String, edge> graph,
* @param graph the graph
* @return full analysis report
*/
public static ChordalReport analyze(Graph<String, edge> graph) {
public static ChordalReport analyze(Graph<String, Edge> graph) {
int vc = graph != null ? graph.getVertexCount() : 0;
int ec = graph != null ? graph.getEdgeCount() : 0;

Expand Down
Loading
Loading