I implemented Vehicle Ad-hoc Network in NS3.38 and used default Node class in NS3. also I created Cluster Object that has some attributes. in some conditions I need to remove node from cluster and perhaps add it to another cluster. I use this structure to creating Cluster and add member to it:
Ptr <Cluster> new_cluster = CreateObject <Cluster> ();
new_cluster->SetId(rand());
new_cluster->SetCHNodeId(sender_node_id);
NodeInformation new_member;
new_member.node_id = node->GetId();
new_member.mac_addr = mac_addr;
new_member.last_beacon = Now();
new_cluster->AddMember(new_member);
/* Aggregate the cluster with both CH and member node*/
sender_node->AggregateObject (new_cluster);
node->AggregateObject (new_cluster);
Now I don't know how to de-aggregate cluster from nodes. Thanks for your helps.
I think your goal in this question is clustering nodes and getting each cluster from node object. also each cluster has multi nodes but every node has just one cluster. but the the aggregating is not for this application. it is for "has one" relationship. For doing this you can define a singleton class and save every cluster in it. next you need to add a function to get each cluster by it's id. also you must save cluster id in each node too. I hope this works for you.