Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
s/Degree/DegreeOf/
Browse files Browse the repository at this point in the history
  • Loading branch information
sdboyer committed Apr 18, 2014
1 parent 11a331f commit 085364a
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions directed.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewDirected() MutableGraph {

// Returns the outdegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *mutableDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
func (g *mutableDirected) OutDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand All @@ -38,7 +38,7 @@ func (g *mutableDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
//
// Note that getting indegree is inefficient for directed adjacency lists; it requires
// a full scan of the graph's edge set.
func (g *mutableDirected) InDegree(vertex Vertex) (degree int, exists bool) {
func (g *mutableDirected) InDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand Down Expand Up @@ -250,7 +250,7 @@ func (g *immutableDirected) HasEdge(edge Edge) bool {

// Returns the outdegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *immutableDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
func (g *immutableDirected) OutDegreeOf(vertex Vertex) (degree int, exists bool) {
if exists = g.hasVertex(vertex); exists {
degree = len(g.list[vertex])
}
Expand All @@ -262,7 +262,7 @@ func (g *immutableDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
//
// Note that getting indegree is inefficient for directed adjacency lists; it requires
// a full scan of the graph's edge set.
func (g *immutableDirected) InDegree(vertex Vertex) (degree int, exists bool) {
func (g *immutableDirected) InDegreeOf(vertex Vertex) (degree int, exists bool) {
if exists = g.hasVertex(vertex); exists {
// This results in a double read-lock. Should be fine.
for e := range g.list {
Expand Down
8 changes: 4 additions & 4 deletions graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ type VertexMembershipChecker interface {
HasVertex(Vertex) bool // Whether or not the vertex is present in the set
}

// An InOutDegreeChecker reports the number of edges incident to a given vertex.
// An DegreeChecker reports the number of edges incident to a given vertex.
// TODO use this
type DegreeChecker interface {
DegreeOf(Vertex) (degree int, exists bool) // Number of incident edges; if vertex is present
}

// An InOutDegreeChecker reports the number of in or out-edges a given vertex has.
// An InOutDegreeChecker reports the number of in or out-edges incident to given vertex.
type InOutDegreeChecker interface {
InDegree(Vertex) (degree int, exists bool) // Number of in-edges; if vertex is present
OutDegree(Vertex) (degree int, exists bool) // Number of out-edges; if vertex is present
InDegreeOf(Vertex) (degree int, exists bool) // Number of in-edges; if vertex is present
OutDegreeOf(Vertex) (degree int, exists bool) // Number of out-edges; if vertex is present
}

// An EdgeMembershipChecker can indicate the presence of an edge.
Expand Down
12 changes: 6 additions & 6 deletions graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,28 +318,28 @@ func (s *GraphSuite) TestEachAdjacent(c *C) {

// This test is carefully constructed to be fully correct for directed graphs,
// and incidentally correct for undirected graphs.
func (s *GraphSuite) TestOutDegree(c *C) {
func (s *GraphSuite) TestOutDegreeOf(c *C) {
g := s.Factory.CreateGraphFromEdges(&BaseEdge{"foo", "bar"})

count, exists := g.OutDegree("foo")
count, exists := g.OutDegreeOf("foo")
c.Assert(exists, Equals, true)
c.Assert(count, Equals, 1)

count, exists = g.OutDegree("missing")
count, exists = g.OutDegreeOf("missing")
c.Assert(exists, Equals, false)
c.Assert(count, Equals, 0)
}

// This test is carefully constructed to be fully correct for directed graphs,
// and incidentally correct for undirected graphs.
func (s *GraphSuite) TestInDegree(c *C) {
func (s *GraphSuite) TestInDegreeOf(c *C) {
g := s.Factory.CreateGraphFromEdges(&BaseEdge{"foo", "bar"})

count, exists := g.InDegree("bar")
count, exists := g.InDegreeOf("bar")
c.Assert(exists, Equals, true)
c.Assert(count, Equals, 1)

count, exists = g.InDegree("missing")
count, exists = g.InDegreeOf("missing")
c.Assert(exists, Equals, false)
c.Assert(count, Equals, 0)
}
Expand Down
10 changes: 5 additions & 5 deletions labeled.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func NewLabeledDirected() MutableLabeledGraph {

// Returns the outdegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *labeledDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
func (g *labeledDirected) OutDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand All @@ -141,7 +141,7 @@ func (g *labeledDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
//
// Note that getting indegree is inefficient for directed adjacency lists; it requires
// a full scan of the graph's edge set.
func (g *labeledDirected) InDegree(vertex Vertex) (degree int, exists bool) {
func (g *labeledDirected) InDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand Down Expand Up @@ -335,7 +335,7 @@ func NewLabeledUndirected() MutableLabeledGraph {

// Returns the outdegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *labeledUndirected) OutDegree(vertex Vertex) (degree int, exists bool) {
func (g *labeledUndirected) OutDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand All @@ -347,8 +347,8 @@ func (g *labeledUndirected) OutDegree(vertex Vertex) (degree int, exists bool) {

// Returns the indegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *labeledUndirected) InDegree(vertex Vertex) (degree int, exists bool) {
return g.OutDegree(vertex)
func (g *labeledUndirected) InDegreeOf(vertex Vertex) (degree int, exists bool) {
return g.OutDegreeOf(vertex)
}

// Traverses the set of edges in the graph, passing each edge to the
Expand Down
4 changes: 2 additions & 2 deletions null.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func (g nullGraph) HasVertex(v Vertex) bool {
return false
}

func (g nullGraph) InDegree(Vertex) (degree int, exists bool) {
func (g nullGraph) InDegreeOf(Vertex) (degree int, exists bool) {
return 0, false
}

func (g nullGraph) OutDegree(Vertex) (degree int, exists bool) {
func (g nullGraph) OutDegreeOf(Vertex) (degree int, exists bool) {
return 0, false
}

Expand Down
10 changes: 5 additions & 5 deletions property.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func NewPropertyDirected() MutablePropertyGraph {

// Returns the outdegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *propertyDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
func (g *propertyDirected) OutDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand All @@ -141,7 +141,7 @@ func (g *propertyDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
//
// Note that getting indegree is inefficient for directed adjacency lists; it requires
// a full scan of the graph's edge set.
func (g *propertyDirected) InDegree(vertex Vertex) (degree int, exists bool) {
func (g *propertyDirected) InDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand Down Expand Up @@ -335,7 +335,7 @@ func NewPropertyUndirected() MutablePropertyGraph {

// Returns the outdegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *propertyUndirected) OutDegree(vertex Vertex) (degree int, exists bool) {
func (g *propertyUndirected) OutDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand All @@ -347,8 +347,8 @@ func (g *propertyUndirected) OutDegree(vertex Vertex) (degree int, exists bool)

// Returns the indegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *propertyUndirected) InDegree(vertex Vertex) (degree int, exists bool) {
return g.OutDegree(vertex)
func (g *propertyUndirected) InDegreeOf(vertex Vertex) (degree int, exists bool) {
return g.OutDegreeOf(vertex)
}

// Traverses the set of edges in the graph, passing each edge to the
Expand Down
6 changes: 3 additions & 3 deletions undirected.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewUndirected() MutableGraph {

// Returns the outdegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *mutableUndirected) OutDegree(vertex Vertex) (degree int, exists bool) {
func (g *mutableUndirected) OutDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand All @@ -35,8 +35,8 @@ func (g *mutableUndirected) OutDegree(vertex Vertex) (degree int, exists bool) {

// Returns the indegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *mutableUndirected) InDegree(vertex Vertex) (degree int, exists bool) {
return g.OutDegree(vertex)
func (g *mutableUndirected) InDegreeOf(vertex Vertex) (degree int, exists bool) {
return g.OutDegreeOf(vertex)
}

// Traverses the set of edges in the graph, passing each edge to the
Expand Down
10 changes: 5 additions & 5 deletions weighted.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func NewWeightedDirected() MutableWeightedGraph {

// Returns the outdegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *weightedDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
func (g *weightedDirected) OutDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand All @@ -141,7 +141,7 @@ func (g *weightedDirected) OutDegree(vertex Vertex) (degree int, exists bool) {
//
// Note that getting indegree is inefficient for directed adjacency lists; it requires
// a full scan of the graph's edge set.
func (g *weightedDirected) InDegree(vertex Vertex) (degree int, exists bool) {
func (g *weightedDirected) InDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand Down Expand Up @@ -335,7 +335,7 @@ func NewWeightedUndirected() MutableWeightedGraph {

// Returns the outdegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *weightedUndirected) OutDegree(vertex Vertex) (degree int, exists bool) {
func (g *weightedUndirected) OutDegreeOf(vertex Vertex) (degree int, exists bool) {
g.mu.RLock()
defer g.mu.RUnlock()

Expand All @@ -347,8 +347,8 @@ func (g *weightedUndirected) OutDegree(vertex Vertex) (degree int, exists bool)

// Returns the indegree of the provided vertex. If the vertex is not present in the
// graph, the second return value will be false.
func (g *weightedUndirected) InDegree(vertex Vertex) (degree int, exists bool) {
return g.OutDegree(vertex)
func (g *weightedUndirected) InDegreeOf(vertex Vertex) (degree int, exists bool) {
return g.OutDegreeOf(vertex)
}

// Traverses the set of edges in the graph, passing each edge to the
Expand Down

0 comments on commit 085364a

Please sign in to comment.