Untitled

 avatar
unknown
java
2 years ago
526 B
1
Indexable
package LAB9;
import java.util.ArrayList;
import java.util.List;

public class GraphNode
{
    char label;
    List<GraphEdge> edgeList;

    // Constructor
    public GraphNode(char label)
    {
        this.label = label;
        this.edgeList = new ArrayList<>();
    }

    // Add an edge to the node
    public void addEdge(GraphEdge edge)
    {
        // Only add the edge if the 'to' node is not the same as the current node
        if (edge.toNode != this)
        {
            edgeList.add(edge);
        }
    }
}
Editor is loading...