Skip to content

The output on top nodes have the same value on id and label #52

@samuelbudimansigit

Description

@samuelbudimansigit

The result on SwedenGraph and SchemaGraph both have the same result on the between the id and label.
This source code should represent the top 10 node with the highest number of Betweenness Centrality, but on the source code given, there are no representing value of Betweeness Centrality.

It happen because the function in namesDict.setdefault(param1,param2), set the value default to param2 if the dic[param1] is none. Therefor on the code, the namesDict is never been set before (always have none value). So self.namesDict.setdefault(str(key),str[key]) will always return the str[key] (which is the value of the id)
after

These are the solution i found :
Change :
for key in map: output += "nodeID: %d centrality: %f\n" % (key, map[key]) index += 1 if (index <= 10): label = self.namesDict.setdefault(str(key),str[key]) topNodes += "\tnodeID: %d label: %s\n" % (key, label) return output, topNodes
before

To :
for key in map: output += "nodeID: %d centrality: %f\n" % (key, map[key]) index += 1 if (index <= 10): label = self.namesDict.setdefault(str(key), map[key]) topNodes += "\tnodeID: %d label: %s\n" % (key, label) return output, topNodes

after

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions