Skip to content

Commit 613d963

Browse files
committed
Implement additional graph generators
1 parent 7c24266 commit 613d963

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ Go-Network is a Go package for the creation, manipulation, and study of the stru
55

66
#### Supported graph generation algorithms
77
- Classic algorithms
8-
- [Complete graph]()
98
- [Circular ladder graph]()
9+
- [Circulant graph]()
10+
- [Complete graph]()
11+
- [Cycle graph]()
1012
- [Empty graph]()
1113
- [Ladder graph]()
1214
- [Lollipop graph]()

model/generator_classic.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func LollipopGraph(completeGraphSize int, pathGraphSize int) *UndirectedGraph {
234234
return g
235235
}
236236

237-
// CycleGraph returns a path graph.
237+
// CycleGraph returns a cyrcle graph.
238238
func CycleGraph(numberOfNodes int) *UndirectedGraph {
239239
g := &UndirectedGraph{}
240240
//generate a Cycle graph
@@ -247,4 +247,18 @@ func CycleGraph(numberOfNodes int) *UndirectedGraph {
247247
return g
248248
}
249249

250-
//balanced tree, binomial tree, barbell graph, complete multipartite graph, circulant graph, dorogovtsev goltsev mendes graph, full rary tree
250+
// CirculantGraph returns a circulant graph of n nodes and .
251+
func CirculantGraph(numberOfNodes int, offset int) *UndirectedGraph {
252+
g := &UndirectedGraph{}
253+
//generate a Circulant graph
254+
for i := 0; i < numberOfNodes; i++ {
255+
g.AddEdge(Edge{
256+
Node1: Node(i),
257+
Node2: Node((i + offset) % numberOfNodes),
258+
})
259+
}
260+
261+
return g
262+
}
263+
264+
//balanced tree, binomial tree, barbell graph, complete multipartite graph, dorogovtsev goltsev mendes graph, full rary tree

0 commit comments

Comments
 (0)