
Public Member Functions | |
| Vertex (Object userObject) | |
| void | addAdjacentVertex (Vertex vertex) |
| Object | getUserObject () |
| boolean | equals (Object obj) |
| int | hashCode () |
Package Functions | |
| int | getColor () |
| List< Vertex > | getAdjacencyList () |
| void | setColor (int color) |
Static Package Attributes | |
| static final int | WHITE = 1 |
| static final int | GRAY = 2 |
| static final int | BLACK = 3 |
Private Attributes | |
| int | m_color |
| List< Vertex > | m_adjacencyList |
| Object | m_userObject |
A vertex of the graph that the TopologicalSort can work on.
| alma::acs::algorithms::Vertex::Vertex | ( | Object | userObject | ) | [inline] |
Constructor that wraps a node in the graph that has to be sorted.
The userObject must implement reasonable equals() and hashCode() methods.
| userObject | the application's graph node, to be retrieved later through getUserObject |
References m_adjacencyList, and m_userObject.
| void alma::acs::algorithms::Vertex::addAdjacentVertex | ( | Vertex | vertex | ) | [inline] |
Adds a dependent vertex to this vertex.
The direction of the graph is from "must occur first" to "may occur later". If node B depends on node A, then call vertexA.addAdjacentVertex(vertexB).
To use the example from Cormen, if you want to figure out in which order to put on your clothes, the vertex for socks must point to the vertex for shoes, stating that socks must be put on before you can put on your shoes, or in other words, that shoes depend on socks. So add the shoe vertex to the sock's adjacent vertex list.
| vertex | another vertex that depends on this vertex. |
References m_adjacencyList.
Referenced by alma::acs::algorithms::TopologicalSortTest::createGarmentVertices().
| boolean alma::acs::algorithms::Vertex::equals | ( | Object | obj | ) | [inline] |
References m_userObject.
| List<Vertex> alma::acs::algorithms::Vertex::getAdjacencyList | ( | ) | [inline, package] |
References m_adjacencyList.
Referenced by alma::acs::algorithms::TopologicalSort::dfsVisit().
| int alma::acs::algorithms::Vertex::getColor | ( | ) | [inline, package] |
References m_color.
Referenced by alma::acs::algorithms::TopologicalSort::dfsVisit(), and alma::acs::algorithms::TopologicalSort::sort().
| Object alma::acs::algorithms::Vertex::getUserObject | ( | ) | [inline] |
Returns the application's graph node that was wrapped by this vertex.
References m_userObject.
Referenced by alma::acs::algorithms::TopologicalSortTest::testFailOnCyclicGraph(), and alma::acs::algorithms::TopologicalSortTest::testSortDirectedAcyclicGraph().
| int alma::acs::algorithms::Vertex::hashCode | ( | ) | [inline] |
References m_userObject.
| void alma::acs::algorithms::Vertex::setColor | ( | int | color | ) | [inline, package] |
References BLACK, GRAY, m_color, and WHITE.
Referenced by alma::acs::algorithms::TopologicalSort::dfsVisit().
final int alma::acs::algorithms::Vertex::BLACK = 3 [static, package] |
Referenced by setColor().
final int alma::acs::algorithms::Vertex::GRAY = 2 [static, package] |
Referenced by setColor().
List<Vertex> alma::acs::algorithms::Vertex::m_adjacencyList [private] |
Referenced by addAdjacentVertex(), getAdjacencyList(), and Vertex().
int alma::acs::algorithms::Vertex::m_color [private] |
Referenced by getColor(), and setColor().
Object alma::acs::algorithms::Vertex::m_userObject [private] |
Referenced by equals(), getUserObject(), hashCode(), and Vertex().
final int alma::acs::algorithms::Vertex::WHITE = 1 [static, package] |
Referenced by setColor().
1.6.2