Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

Commit 322beb3

Browse files
author
gardener
committed
docs(Edge): replace stub Javadoc with full class-and-method documentation
Edge.java was the original boilerplate from the NetBeans template: - file header "To change this template, choose Tools | Templates" - class-level Javadoc with "@author user" - no documentation at all for the no-arg constructor's intended use - no documentation for the (type, v1, v2) constructor's argument order (recently the source of a real bug in GraphComplementAnalyzer) - no documentation for setWeight/getWeight/setLabel/getLabel This commit: - Adds a proper class-level Javadoc explaining the edge model: type codes (with the canonical f/fs/c/s/sg list), the undirected equality semantics, the weight/label fields, and the optional temporal extent. - Calls out that vertex1/vertex2 are advisory and that analyzers should prefer Graph.getEndpoints(e) for the authoritative endpoints. - Documents the no-arg constructor as framework-only. - Documents the 3-arg constructor and explicitly warns about argument order (the bug fixed in 33518cc happened because callers had swapped the type and vertex arguments without compiler help). - Documents the four trivial accessors so external users / IDE tooltips no longer see naked Javadoc-less methods. No behavior change. Existing Edge and GraphComplement tests still pass.
1 parent 33518cc commit 322beb3

1 file changed

Lines changed: 71 additions & 8 deletions

File tree

Gvisual/src/gvisual/Edge.java

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
11
/*
2-
* To change this template, choose Tools | Templates
3-
* and open the template in the editor.
2+
* Edge.java
3+
*
4+
* Core edge data model for GraphVisual. See class Javadoc below.
45
*/
56

67
package gvisual;
8+
79
/**
10+
* Edge between two vertices in a GraphVisual graph.
11+
*
12+
* <p>An {@code Edge} carries:
13+
* <ul>
14+
* <li>An <b>edge type</b> ({@link #getType()}) drawn from the project's
15+
* relationship categories, with the canonical short codes
16+
* {@code f} (friend), {@code fs} (familiar stranger),
17+
* {@code c} (classmate), {@code s} (stranger), and
18+
* {@code sg} (study group). See {@link EdgeType} for the full
19+
* palette and metadata.</li>
20+
* <li>Two endpoint identifiers ({@link #getVertex1()} and
21+
* {@link #getVertex2()}). The edge is treated as <b>undirected</b>:
22+
* {@code (v1, v2)} equals {@code (v2, v1)} for {@link #equals(Object)}
23+
* and {@link #hashCode()} purposes.</li>
24+
* <li>A scalar {@link #getWeight() weight} (typically interaction
25+
* intensity — frequency × duration).</li>
26+
* <li>An optional human-readable {@link #getLabel() label}.</li>
27+
* <li>Optional <b>temporal extent</b> in the form of an epoch-millis
28+
* start ({@link #getTimestamp()}) and end
29+
* ({@link #getEndTimestamp()}). Untimed edges (both null) are
30+
* considered active at all times.</li>
31+
* </ul>
32+
*
33+
* <p>Note for callers: the {@code vertex1} / {@code vertex2} fields stored
34+
* on an {@code Edge} are advisory. The authoritative endpoints for an edge
35+
* inside a JUNG graph are obtained via
36+
* {@link edu.uci.ics.jung.graph.Graph#getEndpoints(Object)}; analyzers that
37+
* read endpoints should prefer that API.
838
*
9-
* @author user
39+
* <p>This class is mutable but is intended to be treated as effectively
40+
* immutable once inserted into a graph (changing endpoints or type after
41+
* insertion may corrupt analyzer state).
42+
*
43+
* @author sauravbhattacharya001
1044
*/
1145
public class Edge {
1246
private String edgeType;
@@ -44,17 +78,28 @@ public String getVertex2()
4478
}
4579

4680
/**
47-
* Constructor
81+
* No-arg constructor. Leaves all fields at their defaults
82+
* ({@code null} for object fields, {@code 0f} for {@link #getWeight()}).
83+
* Mainly intended for frameworks (deserialization, bean instantiation).
84+
* Prefer {@link #Edge(String, String, String)} for explicit construction.
4885
*/
4986
public Edge()
5087
{
5188
}
5289

5390
/**
54-
* Constructor
55-
* @param edgeType Type of the Edge
56-
* @param vertex1 vertex id
57-
* @param vertex2 vertex id
91+
* Constructs an edge with a type and two endpoints.
92+
*
93+
* <p><b>Argument order matters:</b> the type comes first, followed by
94+
* the two endpoint identifiers. Swapping the order leaves the edge
95+
* with garbage type / vertex fields, which has been a recurring source
96+
* of subtle bugs in callers.
97+
*
98+
* @param edgeType type code (e.g. {@code "f"}, {@code "c"}, {@code "s"});
99+
* see {@link EdgeType}
100+
* @param vertex1 first endpoint id (undirected: order is irrelevant
101+
* for equality)
102+
* @param vertex2 second endpoint id
58103
*/
59104
public Edge(String edgeType,String vertex1,String vertex2)
60105
{
@@ -63,21 +108,39 @@ public Edge(String edgeType,String vertex1,String vertex2)
63108
this.vertex2 = vertex2;
64109
}
65110

111+
/**
112+
* Sets the scalar weight of this edge.
113+
* @param weight non-negative numeric weight (semantics are caller-defined,
114+
* but typically encodes interaction intensity)
115+
*/
66116
public void setWeight(float weight)
67117
{
68118
this.weight = weight;
69119
}
70120

121+
/**
122+
* Returns the scalar weight of this edge.
123+
* @return the weight (default {@code 0f} if never set)
124+
*/
71125
public float getWeight()
72126
{
73127
return this.weight;
74128
}
75129

130+
/**
131+
* Sets the human-readable label for this edge.
132+
* Labels are display-only and do not participate in {@link #equals(Object)}.
133+
* @param label the label, or {@code null} to clear
134+
*/
76135
public void setLabel(String label)
77136
{
78137
this.label = label;
79138
}
80139

140+
/**
141+
* Returns the human-readable label for this edge.
142+
* @return the label, or {@code null} if none was set
143+
*/
81144
public String getLabel()
82145
{
83146
return this.label;

0 commit comments

Comments
 (0)