Esempio n. 1
0
// Calculate and return the pageranks for the given edges
func PageRank(edges *[]Edge, damping float64, multiplier float64) *map[string]float64 {
	g := NewGraph()
	ranks := make(map[string]float64)
	defer g.Cleanup()
	g.PopulateFromEdges(edges)
	result := NewVector()
	result.Initialize(0)
	defer result.Cleanup()
	realOne := C.igraph_real_t(1)
	C.igraph_pagerank(g.graph, C.IGRAPH_PAGERANK_ALGO_PRPACK, result.vec, &realOne,
		C.igraph_vss_all(), C.IGRAPH_DIRECTED, C.igraph_real_t(damping), g.weights.vec, nil)

	for i := 0; i < len(g.vertices); i++ {
		ranks[g.vertices[i].Id] = float64(C.igraph_vector_e(result.vec, C.long(i))) * multiplier
	}
	return &ranks
}
Esempio n. 2
0
// Set the Vector's value at index i to value (float)
// (unclear what happens if index is out of range)
func (v *Vector) SetFloat(value float64, index int) {
	C.igraph_vector_set(v.vec, C.long(index), C.igraph_real_t(value))
}
Esempio n. 3
0
// Set the Vector's value at index i to value (int)
// (unclear what happens if index is out of range)
func (v *Vector) SetInt(value int, index int) {
	C.igraph_vector_set(v.vec, C.long(index), C.igraph_real_t(value))
}