Re: Extra data on vertex

2013-05-07 Thread Avery Ching
Best way is to add it to the vertex value.  The vertex value is meant to 
store any data associated with a particular vertex.


Hope that helps,

Avery

On 5/7/13 7:47 AM, Ahmet Emre Aladağ wrote:

Hi,

1) What's the best way for storing extra data (such as URL) on a 
vertex? I thought this would be through a class variable but I could 
not find the way to access that variable from the neighbor.
For example I'd like to remove the duplicate edges going towards the 
nodes with the same url (Duplicate Removal phase of LinkRank). How 
can I learn my neighbor's url variable: targetUrl?


2) Is removing edges like this a valid approach?


public class LinkRankVertex extends VertexIntWritable, FloatWritable,
NullWritable, FloatWritable {

public String url;
public void removeDuplicateLinks() {
int targetId;
String targetUrl;

SetString urls = new HashSetString();
ArrayListEdgesIntWritable, NullWritable edges = new 
ArrayListEdgesIntWritable, NullWritable();


for (EdgeIntWritable, NullWritable edge : getEdges()) {
targetId = edge.getTargetVertexId().get();
targetUrl = ...??
if (!urls.contains(targetUrl)) {
urls.add(targetUrl);
edges.add(edge);
}
}
setEdges(edges);
}
}

Thanks,
Emre.





Re: Extra data on vertex

2013-05-07 Thread Claudio Martella
Keep in mind that you cannot access a neighbors value directly from a
vertex. What you are proposing now is possible because you are using the
vertex id to store your information (URL), which makes sense in the context
of a web page.
As soon as you will store data in the vertex value, as Avery suggest, you
will have to rely on messages to inform the neighbors of the value.


On Tue, May 7, 2013 at 4:47 PM, Ahmet Emre Aladağ emre.ala...@agmlab.comwrote:

 Hi,

 1) What's the best way for storing extra data (such as URL) on a vertex? I
 thought this would be through a class variable but I could not find the way
 to access that variable from the neighbor.
 For example I'd like to remove the duplicate edges going towards the nodes
 with the same url (Duplicate Removal phase of LinkRank). How can I learn
 my neighbor's url variable: targetUrl?

 2) Is removing edges like this a valid approach?


 public class LinkRankVertex extends VertexIntWritable, FloatWritable,
 NullWritable, FloatWritable {

 public String url;
 public void removeDuplicateLinks() {
 int targetId;
 String targetUrl;

 SetString urls = new HashSetString();
 ArrayListEdgesIntWritable, NullWritable edges = new
 ArrayListEdgesIntWritable, NullWritable();

 for (EdgeIntWritable, NullWritable edge : getEdges()) {
 targetId = edge.getTargetVertexId().get()**;
 targetUrl = ...??
 if (!urls.contains(targetUrl)) {
 urls.add(targetUrl);
 edges.add(edge);
 }
 }
 setEdges(edges);
 }
 }

 Thanks,
 Emre.




-- 
   Claudio Martella
   claudio.marte...@gmail.com