Example #1
0
int vertex_assign_attribute(VertexType* v, char* attr_name, void * val, int type ) {
	if(v==NULL)
		die(-1, "NULL vertex in function: vertex_assign_attribute()\n");
	if(attr_name==NULL)
		die(-1, "NULL attr_name in function: vertex_assign_attribute()\n");
    Attribute* attr = (Attribute*)g_hash_table_lookup(v->attributes, attr_name);
    if (attr != NULL) {
        if ( attr->type != type ) {
    		die(-1, "vertex_assign_attribute: attribute type mismatch error \n");
        }
    }
    else {
        attr = new_attr( type, NULL );
        g_hash_table_insert( v->attributes, attr_name, attr );
    }
    assign_attr( attr, type, val );
    return 0;
}
Example #2
0
int edge_assign_attribute ( EdgeType* e, char * attr_name, void * val, int type ) {
    if(e==NULL)
		die(-1, "NULL edge in function: edge_assign_attribute()\n");
	if(attr_name==NULL)
		die(-1, "NULL attr_name in function: edge_assign_attribute()\n");
	Attribute* attr = (Attribute*)g_hash_table_lookup(e->attributes, attr_name);
    if (attr != NULL) {
        if ( attr->type != type ) {
    		die(-1, "edge_assign_attribute: attribute type mismatch error \n");
        }
    }
    else {
        attr = new_attr( type, NULL );
        g_hash_table_insert( e->attributes, attr_name, attr );
    }
    assign_attr( attr, type, val );
    return 0;
}
Example #3
0
int vertex_assign_attribute(VertexType* v, char* attr_name, void * val, int type ) {
    if(v==NULL)
        die(-1, "NULL vertex in function: vertex_assign_attribute()\n");
    if(attr_name==NULL)
        die(-1, "NULL attr_name in function: vertex_assign_attribute()\n");
    Attribute* attr = (Attribute*)g_hash_table_lookup(v->attributes, attr_name);
    if (attr != NULL) {
        if ( attr->type != type ) {
            die(-1, "vertex_assign_attribute: attribute type mismatch error \n");
        }
    }
    else {
        attr = new_attr( type, NULL );
        g_hash_table_insert( v->attributes, attr_name, attr );
        // GC: in  FileReadWrite.c, when we read a graph from xml, need to append info
        //   to GC
        gcRef( (void *) attr, DYN_ATTR_T );
    }
    assign_attr( attr, type, val );
    return 0;
}