cioc / textrank

Implementation of TextRank in Go
5 stars 1 forks source link

Question abou graph.go #1

Closed ggaaooppeenngg closed 11 years ago

ggaaooppeenngg commented 11 years ago

in the addEdge If I got from 0 to 1 from 0 to 1 from 0 to 1 three edge, I thought the weight should be 3, in your code is always weighted 1 ,and there are three Edges between 0 and 1. Is it should be like this based on textRank algrithom?

in the Weight I thought it should be like

        sum = 0
    for _, edge := range g.OutBoundEdges[from] {
        if edge.index == to {
            sum+= edge.weight, nil
        }
      return sum
cioc commented 11 years ago
func (g *Graph) AddEdge(from Vertex, to Vertex, weight float64) {
  if g.OutBoundEdges[from] == nil {
    g.OutBoundEdges[from] = make([]Edge, 1, g.maxVertex + 1)
    g.OutBoundEdges[from][0] = Edge{to, weight}
  } else {
    g.OutBoundEdges[from] = append(g.OutBoundEdges[from], Edge{to, weight})
  }
  if g.InBoundEdges[to] == nil {
    g.InBoundEdges[to] = make([]Edge, 1, g.maxVertex + 1)
    g.InBoundEdges[to][0] = Edge{from, weight}
  } else {
    g.InBoundEdges[to] = append(g.InBoundEdges[to], Edge{from, weight})
  }
}

I believe you need to specify the weight of each edge as a float64.

cioc commented 11 years ago

You could add your code to collapse redundant edges into a single edges with a summed weight. That sounds reasonable to me.