Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement getNodeFromId method #1

Open
carolc24 opened this issue Dec 26, 2015 · 0 comments
Open

Implement getNodeFromId method #1

carolc24 opened this issue Dec 26, 2015 · 0 comments

Comments

@carolc24
Copy link
Owner

I think the following method has the wrong docs associated with it:

_GraphfabExport gf_reaction* gf_nw_getRxnp(gf_network *n, size_t i)

Get the node at index i.

Ps what I need is a method like:

index gf_getNodeIndex (char *nodeId);

Unfortunately I don't have a way to get a node from the ID without looping through the nodes, which is probably the simplest way to implement this. Something like:

gf_node gf_nw_getNodeFromId(gf_network *nw, const char id) {
int k;
// add checks here for nw != NULL etc

for(k = 0; k< gf_nw_getNumNodes(nw); ++k) {
if( !strcmp(gf_node_getID(gf_nw_getNodep(nw)) , id) ) {
return gf_nw_getNodep(nw);
}
}

// not found: set some error condition here
}

You need to pass the network to this method or else it doesn't know which network you are referring to (you can have multiple networks loaded in theory - it's never been tested). Since you're passing the network, it's a method on a network object, hence the "gf_nw" prefix. That prefix convention is used throughout the C API. Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant