package com.stephenramthun.datastructures;

import java.util.HashSet;

public class Vertex<V extends Comparable> implements Comparable {
    V value;
    HashSet<Vertex> edges;

    public Vertex(V value) {
        this.value = value;
        this.edges = new HashSet<>();
    }

    public void addEdge(Vertex v) {
        edges.add(v);
    }

    public void removeEdge(Vertex v) {
        edges.remove(v);
    }

    public boolean hasEdge(Vertex v) {
        return edges.contains(v);
    }

    @Override
    @SuppressWarnings("unchecked")
    public int compareTo(Object v) {
        Vertex vertex = (Vertex)v;
        return this.value.compareTo(vertex.value);
    }
}

@@ -64,16 +64,107 @@
 shSet;%0A%0A
+/**%0A * A Vertex helper class for Graph data structures.%0A *%0A * @author Stephen Ramthun%0A */%0A%0A
 public c
@@ -260,16 +260,34 @@
 %3E edges;
+%0A    int inDegree;
 %0A%0A    pu
@@ -383,218 +383,1445 @@
     
-%7D%0A%0A    public void addEdge(Vertex v) %7B%0A        edges.add(v);%0A    %7D%0A%0A    public void removeEdge(Vertex v) %7B%0A        edges.remove(v);%0A    %7D%0A%0A    public boolean hasEdge(Vertex v) %7B%0A        return edges.contains(v)
+    this.inDegree = 0;%0A    %7D%0A%0A    /**%0A     * Adds an edge from this Vertex to another.%0A     * @param v     Vertex to add as an edge.%0A     */%0A    public void addEdge(Vertex v) %7B%0A        edges.add(v);%0A    %7D%0A%0A    /**%0A     * Removes aan edge from this Vertex.%0A     * @param v     Vertex to remove as an edge.%0A     */%0A    public void removeEdge(Vertex v) %7B%0A        edges.remove(v);%0A    %7D%0A%0A    /**%0A     * Checks if this Vertex has an edge connecting it to a specified Vertex.%0A     * @param v     Vertex to check if there is an edge to from this one.%0A     * @return      True if the edge exists.%0A     */%0A    public boolean hasEdge(Vertex v) %7B%0A        return edges.contains(v);%0A    %7D%0A%0A    /**%0A     * Returns the number of edges pointing to this one.%0A     * @return  The number of edges pointing to this one.%0A     */%0A    public int getInDegree() %7B%0A        return inDegree;%0A    %7D%0A%0A    /**%0A     * Decrements the in-degree of this Vertex. Used in graph algorithms, e.g.%0A     * finding a topological ordering of the vertices in a graph.%0A     */%0A    public void decrementInDegree() %7B%0A        inDegree--;%0A    %7D%0A%0A    /**%0A     * Return the value held by this Vertex.%0A     * @return  The value held by this Vertex.%0A     */%0A    public V getValue() %7B%0A        return value;%0A    %7D%0A%0A    /**%0A     * Returns the set of edges from this Vertex.%0A     * @return  The set of edges from this Vertex.%0A     */%0A    public HashSet%3CVertex%3E getEdges() %7B%0A        return edges
 ;%0A  

Add methods for graph algorithms and documentation.