Re: [Neo4j] Regarding Weighted Node

2011-05-04 Thread Mattias Persson
You could index your nodes with weights in an index and then query them in a
sorted manner. For example:

   private Node createWeightedNode( int weight )
   {
   Node node = graphDb.createNode();
   node.setProperty( "weight", 3 );
   graphDb.index().forNodes( "weights" ).add( node, "weight",
   ValueContext.numeric( weight ) );
   }

   Node nodeA = createWeightedNode( 3 );
   Node nodeB = createWeightedNode( 2 );
   Node nodeC = createWeightedNode( 5 );

   // Verbose as hell
   QueryContext query = new QueryContext(
   NumericRangeQuery.newIntRange( "weight", 2, 5, true, true ) )
   .sort( new Sort( new SortField( "weight", SortField.INT, false ) ) );
   for ( Node node : graphDb.index().forNodes( "weights" ).query( query ) )
   {
   System.out.println( node.getProperty( "weight" ) );
   }


2011/5/3 pooja naik 

> Hi Tobias,
>
> I wanted to know whether Neo4j does that sorting for me, rather than me
> externally sorting each time I delete and insert a node
>
> Thanks
> Pooja
>
>
> 
> From: Tobias Ivarsson 
> To: Neo4j user discussions 
> Sent: Tuesday, May 3, 2011 1:20 PM
> Subject: Re: [Neo4j] Regarding Weighted Node
>
> Hi Pooja,
>
> You could add the weight as a property on the nodes.
>
> For inserting the nodes in a particular order, if you have a complete
> dataset when you insert you can always sort it before you insert it. Or did
> I misunderstand your question?
>
> Cheers,
> Tobias
>
> On Tue, May 3, 2011 at 7:24 PM, pooja naik  wrote:
>
> > Hi
> >
> > Is there a way in neo 4j to add weights to the node ?
> >
> > I want to add weights to the node and want to insert and delete nodes in
> > the increasing order of weight?
> >
> > For example:
> >
> > The following is the graph/tree representation I am interested in.
> >
> > Parent
> > node 1 - weight 1
> >
> > Has children with weights
> >
> > Node 2 - weight 3, node 3- weight 5
> >
> >
> >
> >
> >
> >
> > So the insertion of node4 -weight 4 will go before node3- weight 5 and
> > after node 2- 3
> >
> >
> >
> > Regards
> > Pooja
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> Tobias Ivarsson 
> Hacker, Neo Technology
> www.neotechnology.com
> Cellphone: +46 706 534857
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Regarding Weighted Node

2011-05-03 Thread pooja naik
Hi Tobias,

I wanted to know whether Neo4j does that sorting for me, rather than me 
externally sorting each time I delete and insert a node

Thanks
Pooja



From: Tobias Ivarsson 
To: Neo4j user discussions 
Sent: Tuesday, May 3, 2011 1:20 PM
Subject: Re: [Neo4j] Regarding Weighted Node

Hi Pooja,

You could add the weight as a property on the nodes.

For inserting the nodes in a particular order, if you have a complete
dataset when you insert you can always sort it before you insert it. Or did
I misunderstand your question?

Cheers,
Tobias

On Tue, May 3, 2011 at 7:24 PM, pooja naik  wrote:

> Hi
>
> Is there a way in neo 4j to add weights to the node ?
>
> I want to add weights to the node and want to insert and delete nodes in
> the increasing order of weight?
>
> For example:
>
> The following is the graph/tree representation I am interested in.
>
> Parent
> node 1 - weight 1
>
> Has children with weights
>
> Node 2 - weight 3,     node 3- weight 5
>
>
>
>
>
>
> So the insertion of node4 -weight 4 will go before node3- weight 5 and
> after node 2- 3
>
>
>
> Regards
> Pooja
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Tobias Ivarsson 
Hacker, Neo Technology
www.neotechnology.com
Cellphone: +46 706 534857
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Regarding Weighted Node

2011-05-03 Thread Tobias Ivarsson
Hi Pooja,

You could add the weight as a property on the nodes.

For inserting the nodes in a particular order, if you have a complete
dataset when you insert you can always sort it before you insert it. Or did
I misunderstand your question?

Cheers,
Tobias

On Tue, May 3, 2011 at 7:24 PM, pooja naik  wrote:

> Hi
>
> Is there a way in neo 4j to add weights to the node ?
>
> I want to add weights to the node and want to insert and delete nodes in
> the increasing order of weight?
>
> For example:
>
> The following is the graph/tree representation I am interested in.
>
> Parent
> node 1 - weight 1
>
> Has children with weights
>
> Node 2 - weight 3, node 3- weight 5
>
>
>
>
>
>
> So the insertion of node4 -weight 4 will go before node3- weight 5 and
> after node 2- 3
>
>
>
> Regards
> Pooja
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Tobias Ivarsson 
Hacker, Neo Technology
www.neotechnology.com
Cellphone: +46 706 534857
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] Regarding Weighted Node

2011-05-03 Thread pooja naik
Hi 

Is there a way in neo 4j to add weights to the node ?

I want to add weights to the node and want to insert and delete nodes in the 
increasing order of weight?

For example:

The following is the graph/tree representation I am interested in.

Parent
node 1 - weight 1

Has children with weights

Node 2 - weight 3,     node 3- weight 5






So the insertion of node4 -weight 4 will go before node3- weight 5 and after 
node 2- 3



Regards
Pooja
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user