예제 #1
0
/* construct tree from adjcency matrix */
TREENODE* construct_tree(int node_num, int root_index, int **graph)
{
  int i;
  TREENODE *root, *nodes;

  /* allocate memory */
  nodes = (TREENODE*)malloc(sizeof(TREENODE)*node_num);
  if(nodes == NULL)
  {
    printf("Out of memory");
    return NULL;
  }

  /* initialization */
  for(i = 0; i < node_num; i++)
  {
    nodes[i].index = i;
    nodes[i].dims[0] = 0;
    nodes[i].dims[1] = 0;
    nodes[i].potential = NULL;
    nodes[i].message_num = 0;
    nodes[i].messages = NULL;
    nodes[i].locations = NULL;
    nodes[i].child_num = 0;
    nodes[i].children = NULL;
    nodes[i].parent_num = 0;
    nodes[i].parent = NULL;
  }

  /* set root */
  root = nodes + root_index;
  /* construct tree */
  construct(root, NULL, nodes, node_num, graph);

  initialize_message(nodes, node_num);

  return nodes;
}
예제 #2
0
파일: message.c 프로젝트: brl/netifera
void send_auth_failed(struct privd_instance *privd)
{
	initialize_message(privd, PRIVD_RESPONSE_AUTH_FAILED);
	send_message(privd);
}
예제 #3
0
파일: message.c 프로젝트: brl/netifera
void
send_ok(struct privd_instance *privd)
{
	initialize_message(privd, PRIVD_RESPONSE_OK);
	send_message(privd);
}