0

My Problem:

  1. I have a set of nodes, with some nodes are connected by directional edges.
  2. I want to assign the weights to each node and each edge.
  3. Finally I would like to calculate effective node weights based on influence of the connected nodes.

Background:

  1. Currently I am using JUNG to solve my problem.
  2. I looked at JUNG package edu.uci.ics.jung.algorithms.scoring. But not sure if they would help me achieve my objectives.
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • There are many different ways to "calculate [effective] node weights based on influence of the connected nodes". JUNG does indeed provide several different ways to do that in the package that you identified. Please clarify your requirements: what properties will the node weights and edge weights have, and how do you expect them to help determine the 'effective' node weights? What do you expect the semantics of the effective node weights to be? etc. – Joshua O'Madadhain Dec 22 '12 at 16:39
  • Thanks Joshua for taking time to answer. – user1920253 Dec 25 '12 at 22:40
  • (1) Say I have a graph with many nodes of predetermined risk for each node. (2) Now some of these nodes are connected to others with directional edges. These edges have variable thickness. i.e. Depending on the size of the edge, the resultant risk would vary. (3) Now I would like to calculate the effective risk of these nodes based on the connectivity.
    I have seen JUNG scoring packages. I am not sure which algorithm that I need to use based on my requirement. Can you please suggest which would be more appropriate & is there a sample implimentation?
    – user1920253 Dec 25 '12 at 22:48
  • You still don't have a clear enough specification to define an algorithm. Fundamentally, if you want a PageRank-style iterative algorithm, you need to define how risk for node N at time T is defined in terms of risk of N's neighbors (predecessors? successors?) at time T-1. (You should also be able to justify this definition at some level.) Put simply, you have no well-defined objectives, so it's impossible to advise you on how to achieve them. Until you've done so, this is essentially a question in model design and has nothing to do with any particular software. – Joshua O'Madadhain Dec 28 '12 at 04:33

2 Answers2

1

One approach if represent your node as a Java class, and weight as a property of this class. You can keep a set of edges as the fields of the class, and implement a method to calculate effective weight (eg: getEffectiveWeight())

gerrytan
  • 40,313
  • 9
  • 84
  • 99
  • True. JUNG already provides all these basic framework wot work with graph. My question is more from a Graph algorithm (ex: PageRank or r EigenvectorCentrality) as how I could assign a node weight and use these algorithms to find the influence of these edges. – user1920253 Dec 21 '12 at 00:05
  • PageRank does not use node weights to determine the per-node scores. If (for example) you consider the (initial) node weights to be the probabilities of starting at each node, this probability distribution is actually completely irrelevant to the final answer, provided that the graph is strongly connected. (PageRankWithPriors is a different matter.) – Joshua O'Madadhain Dec 22 '12 at 16:42
0

Two approaches come to mind:

  1. Add a weight field to your Node and Edge classes.

  2. Create two Maps. One uses Nodes as keys and the other uses Edges as keys. Then store the weight as the value.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • If we're talking about JUNG's PageRank and related algorithms, this isn't necessary: node weights are (generally) assigned by the algorithm and edge weights can be supplied in the constructor if desired. – Joshua O'Madadhain Dec 22 '12 at 16:44