0

I want lmd algorithm in r that described as:

Given a graph G, V is the set of nodes, suppose the node v has the largest degree, v is a local maximal-degree node, because the degrees of the nodes in v’s neighbors set is smaller or equal to v’s degree. Put v into the local maximal degree nodes set H and remove v and its neighbors with degree smaller than v from V. In the remaining nodes in V, if the node with the largest degree is a local maximal degree node, remove the node and its neighbors whose degree is smaller than the local maximal degree node. If the nodes with the largest degree is not a local maximal degree node, remove it from V. Repeat the process, until all local maximal nodes are found and not any node is left in V. We should not compare every node and its neighbor to determine whether it is a local maximal degree node. We do not to analyze the nodes which are in the local maximal degree node’s neighbor set and have smaller degree. The worst time complexity is O(dn) to finding all the local maximal degree nodes, where n is the number of nodes in network and d is the average degree of nodes.

i write this code in r:

library(igraph)
seedselection <-function(graph){
  vecount<-vcount(graph) 
  for (i in 1:vecount) {
    j<-max(degree(graph))
    seed <-j
    delete.vertices(graph, j)
    delete.vertices(graph,neighbors(graph, j))
  }
  seeds <- list(seed)
  print(seeds)
}

but result of this code is false?

r2evans
  • 141,215
  • 6
  • 77
  • 149
fatima
  • 1
  • 1
  • Usually you don't need the function to *print* a value (a side-effect that you don't normally capture), you need it to *return* a value (which you then use in subsequent calculations/plots/etc). Regardless, it will really help if you read about [minimal examples](http://stackoverflow.com/help/mcve) and [reproducible examples](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and then provide some data. Also, what are `delete.vertices`, `neighbors`, `degree`, and `vcount`? They aren't base R functions. (Hint: are you using a library? Need to state that too.) – r2evans Jul 23 '16 at 12:58
  • yes.i used library(igraph) – fatima Jul 25 '16 at 07:29

0 Answers0