diff --git a/pkg/pagerank/pagerank.go b/pkg/pagerank/pagerank.go index 59ee957..b9b1f02 100644 --- a/pkg/pagerank/pagerank.go +++ b/pkg/pagerank/pagerank.go @@ -9,7 +9,6 @@ import ( "github/pippellia-btc/crawler/pkg/graph" "github/pippellia-btc/crawler/pkg/walks" "math/rand/v2" - "slices" ) var ErrEmptyWalkStore = errors.New("the walk store is empty") @@ -251,28 +250,6 @@ func frequencyMap(path []graph.ID) map[graph.ID]float64 { return freqs } -// targetFrequency returns the frequency of visits for each target -func targetFrequency(targets []graph.ID, path []graph.ID) []float64 { - if len(targets) == 0 || len(path) == 0 { - return nil - } - - total := len(path) - freq := 1.0 / float64(total) - freqs := make([]float64, len(targets)) - - for _, node := range path { - idx := slices.Index(targets, node) - if idx == -1 { - continue - } - - freqs[idx] += freq - } - - return freqs -} - // returns a random element of a slice. It panics if the slice is empty or nil. func randomElement[S []E, E any](s S) E { return s[rand.IntN(len(s))] diff --git a/pkg/pagerank/pagerank_test.go b/pkg/pagerank/pagerank_test.go index 80b0284..4e2ecbc 100644 --- a/pkg/pagerank/pagerank_test.go +++ b/pkg/pagerank/pagerank_test.go @@ -57,29 +57,6 @@ func BenchmarkFrequencyMap(b *testing.B) { } } -func BenchmarkTargetFrequency(b *testing.B) { - targets := make([]graph.ID, 10) - for i := range 10 { - targets[i] = randomID(1000) - } - - sizes := []int{10000, 100000, 1000000} - for _, size := range sizes { - b.Run(fmt.Sprintf("size=%d", size), func(b *testing.B) { - - path := make([]graph.ID, size) - for i := range sizes { - path[i] = randomID(size / 10) - } - - b.ResetTimer() - for range b.N { - targetFrequency(targets, path) - } - }) - } -} - func randomID(n int) graph.ID { return graph.ID(strconv.Itoa(rand.IntN(n))) }