Exemple #1
0
//this function finds (or creates if they don't exist) the two nodes and then adds each node to each other's ConnectedNodes list
void addedge(char* a,char* b,int weight, LinkedList* list)
{
	//find (or create) node 'a'
    GraphNode* anode = findNode(a, list);
	//find (or create) node 'b'
    GraphNode* bnode = findNode(b, list);
	//add the nodes to each other's list of connected nodes.
	addvert(anode,bnode,weight);

}
Exemple #2
0
 int addvert(const vec &pos, const vec2 &tc = vec2(0, 0), const bvec &norm = bvec(128, 128, 128), const bvec &tangent = bvec(128, 128, 128), uchar bitangent = 128)
 {
     vertex vtx;
     vtx.pos = pos;
     vtx.tc = tc;
     vtx.norm = norm;
     vtx.reserved = 0;
     vtx.tangent = tangent;
     vtx.bitangent = bitangent;
     return addvert(vtx);
 }
Exemple #3
0
//adds each node to the other's connectedNodes list 
int addvert(GraphNode* a, GraphNode* b,int weight)
{
	LinkedListNode* tmpnode = a->connectedNodes->head;
	//see if node b is in a's list of connected node (if so we exit)
	while (tmpnode != NULL)
	{
		if (!strcmp(((GraphNode*)(((ConnectedNode*)(tmpnode->data))->node))->name, b->name))
			return 0;
		tmpnode = tmpnode->next;
	}
	ConnectedNode* conNode = (ConnectedNode*)malloc(sizeof(ConnectedNode));
	conNode->node = b;
	conNode->weight = weight;
	insertLast(a->connectedNodes, (void*)conNode);
	(a->connectedNodes->len)++;
	addvert(b,a,weight);
	static int x = -1;
	return 1;
}