Exemple #1
0
static int dfs(Agnode_t * n, Agedge_t * link, int warn)
{
    Agedge_t *e;
    Agedge_t *f;
    Agraph_t *g = agrootof(n);

    MARK(n) = 1;

    for (e = agfstin(g, n); e; e = f) {
	f = agnxtin(g, e);
	if (e == link)
	    continue;
	if (MARK(agtail(e)))
	    agdelete(g, e);
    }

    for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
	if (MARK(aghead(e))) {
	    if (!warn) {
		warn++;
		fprintf(stderr,
			"warning: %s has cycle(s), transitive reduction not unique\n",
			agnameof(g));
		fprintf(stderr, "cycle involves edge %s -> %s\n",
			agnameof(agtail(e)), agnameof(aghead(e)));
	    }
	} else
	    warn = dfs(aghead(e), AGOUT2IN(e), warn);
    }

    MARK(n) = 0;
    return warn;
}
static void svg_begin_graph(GVJ_t * job)
{
    obj_state_t *obj = job->obj;

    gvputs(job, "<!--");
    if (agnameof(obj->u.g)[0]) {
	gvputs(job, " Title: ");
	gvputs(job, xml_string(agnameof(obj->u.g)));
    }
    gvprintf(job, " Pages: %d -->\n",
	     job->pagesArraySize.x * job->pagesArraySize.y);

    gvprintf(job, "<svg width=\"%dpt\" height=\"%dpt\"\n",
	     job->width, job->height);
    gvprintf(job, " viewBox=\"%.2f %.2f %.2f %.2f\"",
	job->canvasBox.LL.x,
	job->canvasBox.LL.y,
	job->canvasBox.UR.x,
	job->canvasBox.UR.y);
    /* namespace of svg */
    gvputs(job, " xmlns=\"http://www.w3.org/2000/svg\"");
    /* namespace of xlink */
    gvputs(job, " xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
    gvputs(job, ">\n");
}
	void GraphvizPlotter::parseEdges(Agraph_t *g, GraphComponent *g_component, processedProperties *props) {
		Agnode_t *from_node = agfstnode(g);
		// nacteme prvni vrchol
		while (from_node) {

			// nacteme hranu, ktera z vrcholu vychazi
			Agedge_t *e = agfstout(g, from_node);
			while (e) {
				// pokud byla tato hrana uz zpracovana, preskocime
				if (isWalkedObject(e, &props->edges)) {
					e = agnxtout(g, e);
					continue;
				}
				// nacteme vrchol, ke kteremu hrana vede
				Agnode_t *to_node = e->node;

				// pridame hranu do datoveho modelu
				Edge *edge = g_component->addEdge(agnameof(from_node), agnameof(to_node));
				// pridame vsechny jeho atributy
				parseEdgeAttrs(e, edge, props);

				// pridame mezi zpracovane
				props->edges.push_back(e);
				// nacteme dalsi hranu, ktera vede z daneho vrcholu
				e = agnxtout(g, e);
			}

			// nacteme dalsi vrchol
			from_node = agnxtnode(g, from_node);
		}
	}
Exemple #4
0
static void map_begin_page(GVJ_t * job)
{
    obj_state_t *obj = job->obj;
    char *s;

    switch (job->render.id) {
    case FORMAT_IMAP:
        gvputs(job, "base referer\n");
        if (obj->url && obj->url[0]) {
	    gvputs(job, "default ");
	    gvputs(job, xml_string(obj->url));
	    gvputs(job, "\n");
	}
        break;
    case FORMAT_ISMAP:
        if (obj->url && obj->url[0]) {
	    gvputs(job, "default ");
	    gvputs(job, xml_string(obj->url));
	    gvputs(job, " ");
	    gvputs(job, xml_string(agnameof(obj->u.g)));
	    gvputs(job, "\n");
	}
        break;
    case FORMAT_CMAPX:
	s = xml_string(agnameof(obj->u.g));
	gvputs(job, "<map id=\"");
	gvputs(job, s);
	gvputs(job, "\" name=\"");
	gvputs(job, s);
	gvputs(job, "\">\n");
        break;
    default:
	break;
    }
}
/** Determine the current active state.
 * Note that there might be multiple active states if there are sub-fsms. It will
 * only consider the active state of the bottom-fsm.
 * @return the current active state
 */
std::string
SkillGuiGraphDrawingArea::get_active_state(graph_t *graph)
{
  if (! graph) {
    return "";
  }

  // Loop through the nodes in the graph/subgraph and find the active node
  for (node_t *n = agfstnode(graph); n; n = agnxtnode(graph, n)) {
      const char *actattr = agget(n, (char *)"active");
      if (actattr && (strcmp(actattr, "true") == 0) ) {
          node_t *mn = agmetanode(graph);
          graph_t *mg = mn->graph;
          // Check to see if the node has an edge going into a subgraph
          for (edge_t *me = agfstout(mg, mn); me; me = agnxtout(mg, me)) {
              graph_t *subgraph = agusergraph(me->head);
              for (edge_t *e = agfstout(graph, n); e; e = agnxtout(graph, e)) {
                  for (node_t *subnode = agfstnode(subgraph); subnode; subnode = agnxtnode(subgraph, subnode)) {
                      if (agnameof(subnode) == agnameof(e->head)) {
                          // The node goes into a subgraph, recursively find and return the active subnode name
                          return get_active_state(subgraph);
                      }
                  }
              }
          }
          // The node has no subgraph, return the name of the active node
          return agnameof(n);
      }
  }

  return "";
}
Exemple #6
0
aresta_t add_aresta(grafo g, vertice_t v, Agnode_t *v_cgraph, Agedge_t *a){
    aresta_t nova_aresta;
    Agnode_t * vertice_dest;
    char *peso;

    // aloca aresta
    nova_aresta = (aresta_t) malloc(sizeof(struct aresta_t));
    // insere aresta na fila
    nova_aresta->next = v->aresta;
    v->aresta = nova_aresta;
    // seta peso
    peso = agget(a, (char *)"peso");
    if ( peso && *peso ) {
        nova_aresta->peso = atof(peso);
	g->peso = 1;
    } else
        nova_aresta->peso = PESO_DEFAULT;

    // seta ponteiro da aresta para vertice
    if (!strcmp(agnameof(v_cgraph), agnameof(aghead(a))) )
        vertice_dest = agtail(a);
    else
        vertice_dest = aghead(a);

    nova_aresta->vertice = get_vertice(vertice_dest);

    return nova_aresta;
}
Exemple #7
0
grafo le_grafo(FILE *input){
	if (!input)
		return NULL;
	
	Agraph_t *Ag = agread(input, NULL);
	
	if(!Ag)
		return NULL;

	grafo g = cria_grafo(agnameof(Ag), agisdirected(Ag), contem_pesos(Ag), agnnodes(Ag));

	for (Agnode_t *Av=agfstnode(Ag); Av; Av=agnxtnode(Ag,Av)) {
        	cria_vertice(g, agnameof(Av));
	}

    	for (Agnode_t *Av=agfstnode(Ag); Av; Av=agnxtnode(Ag,Av)) {
       		for (Agedge_t *Ae=agfstout(Ag,Av); Ae; Ae=agnxtout(Ag,Ae)) {
           		vertice u = v_busca(g, agnameof(agtail(Ae)));
           		vertice v = v_busca(g, agnameof(aghead(Ae)));
           		cria_vizinhanca(g, u, v, get_peso(Ae));
       		}
    	}
	
	agclose(Ag);
	agfree(Ag, NULL);
	return g;
}  
Exemple #8
0
static void map_edge(edge_t * e)
{
    int j, k;
    bezier bz;

    if (ED_spl(e) == NULL) {
	if ((Concentrate == FALSE) && (ED_edge_type(e) != IGNORED))
	    agerr(AGERR, "lost %s %s edge\n", agnameof(agtail(e)),
		  agnameof(aghead(e)));
	return;
    }
    for (j = 0; j < ED_spl(e)->size; j++) {
	bz = ED_spl(e)->list[j];
	for (k = 0; k < bz.size; k++)
	    bz.list[k] = map_point(bz.list[k]);
	if (bz.sflag)
	    ED_spl(e)->list[j].sp = map_point(ED_spl(e)->list[j].sp);
	if (bz.eflag)
	    ED_spl(e)->list[j].ep = map_point(ED_spl(e)->list[j].ep);
    }
    if (ED_label(e))
	ED_label(e)->pos = map_point(ED_label(e)->pos);
    if (ED_xlabel(e))
	ED_xlabel(e)->pos = map_point(ED_xlabel(e)->pos);
    /* vladimir */
    if (ED_head_label(e))
	ED_head_label(e)->pos = map_point(ED_head_label(e)->pos);
    if (ED_tail_label(e))
	ED_tail_label(e)->pos = map_point(ED_tail_label(e)->pos);
}
Exemple #9
0
static char *nameOf(void *obj, agxbuf * xb)
{
    Agedge_t *ep;
    switch (agobjkind(obj)) {
#ifndef WITH_CGRAPH
    case AGGRAPH:
#else
    case AGRAPH:
#endif
	agxbput(xb, agnameof(((Agraph_t *) obj)));
	break;
    case AGNODE:
	agxbput(xb, agnameof(((Agnode_t *) obj)));
	break;
    case AGEDGE:
	ep = (Agedge_t *) obj;
	agxbput(xb, agnameof(agtail(ep)));
	agxbput(xb, agnameof(aghead(ep)));
	if (agisdirected(agraphof(aghead(ep))))
	    agxbput(xb, "->");
	else
	    agxbput(xb, "--");
	break;
    }
    return agxbuse(xb);
}
Exemple #10
0
static void
cloneSubg (Agraph_t* parent, Agraph_t* sg, Dt_t* emap)
{
    Agraph_t* subg;
    Agnode_t* t;
    Agedge_t* e;
    Agnode_t* newt;
    Agedge_t* newe;
    Agraph_t* newg;

    if (is_a_cluster(sg)) {
	newg = agsubg (parent, agnameof(sg), 1);
	parent = newg; 

	for (t = agfstnode(sg); t; t = agnxtnode(sg, t)) {
	    newt = agnode(newg, agnameof(t), 0);
            agsubnode(newg, newt, 1);
	    /* if e is in sg, both end points are, so we can use out edges */
	    for (e = agfstout(sg, t); e; e = agnxtout(sg, e)) {
		newe = mapEdge (emap, e);
		agsubedge(newg, newe, 1);
	    }
	}
    }

    for (subg = agfstsubg(sg); subg; subg = agnxtsubg(subg)) {
	cloneSubg(parent, subg, emap);
    }
}
/* finishEdge:
 * Finish edge generation, clipping to nodes and adding arrowhead
 * if necessary, and adding edge labels
 */
static void
finishEdge (graph_t* g, edge_t* e, Ppoly_t spl, int flip, pointf p, pointf q)
{
    int j;
    pointf *spline = N_GNEW(spl.pn, pointf);
    pointf p1, q1;

    if (flip) {
	for (j = 0; j < spl.pn; j++) {
	    spline[spl.pn - 1 - j] = spl.ps[j];
	}
	p1 = q;
	q1 = p;
    }
    else {
	for (j = 0; j < spl.pn; j++) {
	    spline[j] = spl.ps[j];
	}
	p1 = p;
	q1 = q;
    }
    if (Verbose > 1)
	fprintf(stderr, "spline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e)));
    clip_and_install(e, aghead(e), spline, spl.pn, &sinfo);
    free(spline);

    addEdgeLabels(g, e, p1, q1);
}
Exemple #12
0
grafo le_grafo(FILE *input) {
    int i;
    Agnode_t *v;
    Agedge_t *a;
    Agraph_t *g_cgraph;

    g_cgraph = agread(input, NULL);

    if ( !g_cgraph )
        return NULL;

    // Cria grafo
    grafo g = (grafo) malloc(sizeof(struct grafo));
    g->tipo = agisdirected(g_cgraph);
    g->vertice = (vertice_t) malloc(agnnodes(g_cgraph) * sizeof(struct vertice_t));
    //Copia nome do grafo
    g->nome = (char *) malloc(strlen(agnameof(g_cgraph))+1);
    strcpy(g->nome, agnameof(g_cgraph));

    if (!g->vertice)
        return NULL;


    i = 0;
    // Copia vertices
    for (v=agfstnode(g_cgraph ); v; v=agnxtnode(g_cgraph ,v), i++) {
        // copia nome
        g->vertice[i].nome = (char *) malloc(strlen(agnameof(v))+1);
        strcpy(g->vertice[i].nome, agnameof(v));

	// inicializa lista de arestas
	g->vertice[i].aresta = NULL;
	// seta next vertice
	if (i != agnnodes(g_cgraph) - 1)
		g->vertice[i].next = &g->vertice[i+1];

        //set atribute
        Agnodeinfo_t *p;
        p = (Agnodeinfo_t*) agbindrec(v,"Agnodeinfo_t",sizeof(Agnodeinfo_t),TRUE);
        p->ref_v = &g->vertice[i];

    }
    g->vertice[i-1].next = NULL;

    //Copia arestas
    i = 0;
    for (v=agfstnode(g_cgraph); v; v=agnxtnode(g_cgraph,v), i++) {
        if (g->tipo == NAODIRECIONADO){
            for (a=agfstedge(g_cgraph,v); a; a=agnxtedge(g_cgraph,a,v))
                add_aresta(g, &g->vertice[i], v, a);
        } else {
            for (a=agfstout(g_cgraph,v); a; a=agnxtout(g_cgraph,a))
                add_aresta(g, &g->vertice[i], v, a);
        }
    }

    free(g_cgraph);
    return g;

}
static void vrml_begin_edge(GVJ_t *job)
{
    obj_state_t *obj = job->obj;
    edge_t *e = obj->u.e;

    IsSegment = 0;
    gvprintf(job, "# edge %s -> %s\n", agnameof(agtail(e)), agnameof(aghead(e)));
    gvputs(job,   " Group { children [\n");
}
bool rm(Agnode_t *n)
{
    if (!n)
        return false;
    // removal of the protonode is not permitted
    if (agnameof(n)[0] == '\001' && strcmp (agnameof(n), "\001proto") ==0)
        return false;
    agdelete(agraphof(n), n);
    return true;
}
Exemple #15
0
static void writenodeandport(FILE * f, node_t * node, char *port)
{
    char *name;
    if (IS_CLUST_NODE(node))
	name = canon (agraphof(node), strchr(agnameof(node), ':') + 1);
    else
	name = agcanonStr (agnameof(node));
    printstring(f, " ", name); /* slimey i know */
    if (port && *port)
	printstring(f, ":", agcanonStr(port));
}
static void tkgen_begin_graph(GVJ_t * job)
{
    obj_state_t *obj = job->obj;

    gvputs(job, "#");
    if (agnameof(obj->u.g)[0]) {
        gvputs(job, " Title: ");
	gvputs(job, tkgen_string(agnameof(obj->u.g)));
    }
    gvprintf(job, " Pages: %d\n", job->pagesArraySize.x * job->pagesArraySize.y);
}
bool rm(Agedge_t *e)
{
    if (!e)
        return false;
    // removal of the protoedge is not permitted
    if ((agnameof(aghead(e))[0] == '\001' && strcmp (agnameof(aghead(e)), "\001proto") == 0)
     || (agnameof(agtail(e))[0] == '\001' && strcmp (agnameof(agtail(e)), "\001proto") == 0))
        return false;
    agdelete(agroot(agraphof(aghead(e))), e);
    return true;
}
Exemple #18
0
//------------------------------------------------------------------------------
long int *obter_matriz_adjacencia(Agraph_t *g, vertice lista_vertices, int grafo_ponderado, int grafo_direcionado, unsigned int n_vertices) {
  Agedge_t *a;
  Agnode_t *v;
  long int *matriz = NULL;
  char *peso;
  char peso_string[] = "peso";
  unsigned i;
  int cauda_indice, cabeca_indice;

  if(n_vertices > 0) {
    /* Aloca a quantidade de memória necessária para armazenar todas as arestas */
    matriz = (long int *) malloc(sizeof(long int) * n_vertices * n_vertices);

    if(matriz != NULL) {
      /* Inicializa a matriz */
      for(i = 0; i < n_vertices * n_vertices; ++i) {
        matriz[i] = 0;
      }

      /* Percorre todas as arestas do grafo */
      for(v = agfstnode(g); v != NULL; v = agnxtnode(g, v)) {
        for(a = agfstedge(g, v); a != NULL; a = agnxtedge(g, a, v)) {
          /* Obtêm os vértices de origem e destino da aresta */
          cauda_indice = encontra_vertice(lista_vertices, n_vertices, agnameof(agtail(a)));
          cabeca_indice = encontra_vertice(lista_vertices, n_vertices, agnameof(aghead(a)));

          /* Caso não sejam encontrados, retorna com um erro */
          if(cauda_indice == -1 || cabeca_indice == -1) {
            free(matriz);
            return NULL;
          }

          /* Se o grafo é ponderado, armazena o valor do peso (se existir) na matriz,
             caso contrário armazena o valor 1 */
          if(grafo_ponderado == 1) {
            peso = agget(a, peso_string);
            matriz[cauda_indice * (int) n_vertices + cabeca_indice] = (peso != NULL && *peso != '\0') ? atol(peso) : 0;
          } else {
            matriz[cauda_indice * (int) n_vertices + cabeca_indice] = 1;
          }

          /* Se o grafo não é direcionado, então M[i,j] = M[j,i] */
          if(grafo_direcionado != 1) {
            matriz[cabeca_indice * (int) n_vertices + cauda_indice] = matriz[cauda_indice * (int) n_vertices + cabeca_indice];
          }
        }
      }
    }
  }

  return matriz;
}
Exemple #19
0
void print_edge(edgelist * list)
{
    edgelistitem *temp;
    Agedge_t *ep;

    for (temp = (edgelistitem *) dtflatten(list); temp;
	 temp = (edgelistitem *) dtlink(list, (Dtlink_t *) temp)) {
	ep = temp->edge;
	fprintf(stderr, "%s--", agnameof(agtail(ep)));
	fprintf(stderr, "%s \n", agnameof(aghead(ep)));
    }
    fputs("\n", stderr);
}
Exemple #20
0
/* cloneGraph:
 * Clone node, edge and subgraph structure from src to tgt.
 */
static void cloneGraph(Agraph_t * tgt, Agraph_t * src)
{
    Agedge_t *e;
    Agnode_t *t;
    Agraph_t *sg;

    for (t = agfstnode(src); t; t = agnxtnode(t)) {
	if (!copy(tgt, OBJ(t))) {
	    error(ERROR_FATAL, "error cloning node %s from graph %s",
		  agnameof(t), agnameof(src));
	}
    }
    for (t = agfstnode(src); t; t = agnxtnode(t)) {
	for (e = agfstout(t); e; e = agnxtout(e)) {
	    if (!copy(tgt, OBJ(e))) {
		error(ERROR_FATAL,
		      "error cloning edge (%s,%s)[%s] from graph %s",
		      agnameof(agtail(e)), agnameof(aghead(e)),
		      agnameof(e), agnameof(src));
	    }
	}
    }
    for (sg = agfstsubg(src); sg; sg = agnxtsubg(sg)) {
	if (!cloneSubg(tgt, sg)) {
	    error(ERROR_FATAL, "error cloning subgraph %s from graph %s",
		  agnameof(sg), agnameof(src));
	}
    }
}
Exemple #21
0
/* makePolyline:
 */
static void
makePolyline(graph_t* g, edge_t * e)
{
    Ppolyline_t spl, line = ED_path(e);
    Ppoint_t p0, q0;

    p0 = line.ps[0];
    q0 = line.ps[line.pn - 1];
    make_polyline (line, &spl);
    if (Verbose > 1)
	fprintf(stderr, "polyline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e)));
    clip_and_install(e, aghead(e), spl.ps, spl.pn, &sinfo);
    addEdgeLabels(g, e, p0, q0);
}
Exemple #22
0
static void addCutPts(Agraph_t * tree, Agraph_t * blk)
{
    Agnode_t *n;
    Agnode_t *bn;
    Agnode_t *cn;

    bn = agnode(tree, agnameof(blk), 1);
    for (n = agfstnode(blk); n; n = agnxtnode(blk, n)) {
	if (Cut(n)) {
	    cn = agnode(tree, agnameof(n), 1);
	    agedge(tree, bn, cn, 0, 1);
	}
    }
}
Exemple #23
0
static aresta cria_aresta( lista lv, Agedge_t *e ){

	char *findme = malloc(sizeof(char) * strlen("peso\0")+1);
	strcpy( findme, "peso\0" );
	aresta a    = malloc(sizeof(struct aresta));
	a->visitada = 0;
	a->coberta  = 0; 
	a->origem   = busca_vertice(lv, agnameof(agtail(e)));
	a->destino  = busca_vertice(lv, agnameof(aghead(e)));
	char *peso  = agget( e, findme );
	a->peso     = peso ? strtol(peso,NULL,10) : 0;
	free(findme);
	return a;
}
Exemple #24
0
void prGraph(Agraph_t * g)
{
    Agnode_t *n;
    Agedge_t *e;

    fprintf(stderr, "%s\n", agnameof(g));
    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
	fprintf(stderr, "%s (%x)\n", agnameof(n), (unsigned int) n);
	for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
	    fprintf(stderr, "%s", agnameof(n));
	    fprintf(stderr, " -- %s (%x)\n", agnameof(aghead(e)),
		    (unsigned int) e);
	}
    }
}
Exemple #25
0
/* dfs:
 * Return the number of reversed edges for this component.
 */
static int dfs(Agraph_t * g, Agnode_t * t, int hasCycle)
{
    Agedge_t *e;
    Agedge_t *f;
    Agnode_t *h;

    ND_mark(t) = 1;
    ND_onstack(t) = 1;
    for (e = agfstout(g, t); e; e = f) {
	f = agnxtout(g, e);
	if (agtail(e) == aghead(e))
	    continue;
	h = aghead(e);
	if (ND_onstack(h)) {
	    if (agisstrict(g)) {
		if (agedge(g, h, t, 0, 0) == 0)
		    addRevEdge(g, e);
	    } else {
		char* key = agnameof (e);
		if (!key || (agedge(g, h, t, key, 0) == 0))
		    addRevEdge(g, e);
	    }
	    agdelete(g, e);
	    hasCycle = 1;
	} else if (ND_mark(h) == 0)
	    hasCycle |= dfs(g, h, hasCycle);
    }
    ND_onstack(t) = 0;
    return hasCycle;
}
Exemple #26
0
int main(int argc, char **argv)
{
    Agraph_t *g;
    Agnode_t *n;
    ingraph_state ig;
    int i = 0;
    int code = 0;
    Dict_t *Q;

    init(argc, argv);
    newIngraph(&ig, Files, gread);

    Q = dtopen(&MyDisc, Dtoset);
    while ((g = nextGraph(&ig)) != 0) {
	dtclear(Q);
	if ((n = agnode(g, Nodes[i], 0)))
	    dijkstra(Q, g, n);
	else {
	    fprintf(stderr, "%s: no node %s in graph %s in %s\n",
		    CmdName, Nodes[i], agnameof(g), fileName(&ig));
	    code = 1;
	}
	agwrite(g, stdout);
	fflush(stdout);
	agclose(g);
	i++;
    }
    exit(code);
}
Exemple #27
0
void remove_child(Agraph_t * graph, Agnode_t * node)
{
    Agedge_t *edge;
    Agedge_t *nexte;

    /* Avoid cycles */
    if MARKED
	(node) return;
    MARK(node);

    /* Skip nodes with more than one parent */
    edge = agfstin(node);
    if (edge && (agnxtin(edge) != NULL)) {
	UNMARK(node);
	return;
    }

    /* recursively remove children */
    for (edge = agfstout(node); edge; edge = nexte) {
	nexte = agnxtout(edge);
	if (aghead(edge) != node) {
	    if (verbose)
		fprintf(stderr, "Processing descendant: %s\n",
			agnameof(aghead(edge)));
	    remove_child(graph, aghead(edge));
	    agdeledge(edge);
	}
    }

    agdelnode(node);
    return;
}
Exemple #28
0
//------------------------------------------------------------------------------
static Agraph_t *mostra_grafo(Agraph_t *g) {

  if ( ! g )
    return NULL;

  direcionado = agisdirected(g);

  n_vertices = agnnodes(g);

  n_arestas = agnedges(g);
  
  lista_arestas = constroi_lista();

  printf("strict %sgraph \"%s\" {\n\n",
         agisdirected(g) ? "di" : "",
         agnameof(g)
         );

  mostra_vertices(g);

  printf("\n");

  mostra_arestas();

  printf("}\n");

  destroi_lista(lista_arestas, NULL);

  return g;
}
/** Get position of a state in the graph.
 * @param state_name name of state to get position of
 * @param px upon successful return contains X position value
 * @param py upon succesful return contains Y position value
 * Positions px/py are decimal percentages of
 * graph width/height from left/top. 
 * @return true if node has been found and px/py have been set, false otherwise
 */
bool
SkillGuiGraphDrawingArea::get_state_position(std::string state_name,
					     double &px, double &py)
{
  if (! __graph) {
    return false;
  }

  for (node_t *n = agfstnode(__graph); n; n = agnxtnode(__graph, n)) {
    const char *name = agnameof(n);
    pointf nodepos = ND_coord(n);

    if (state_name == name) {
      boxf bb = GD_bb(__graph);
      double bb_width  = bb.UR.x - bb.LL.x;
      double bb_height = bb.UR.y - bb.LL.y;

      px =       nodepos.x / bb_width;
      py = 1. - (nodepos.y / bb_height);

      return true;
    }
  }

  return false;
}
static void vrml_begin_node(GVJ_t *job)
{
    obj_state_t *obj = job->obj;
    node_t *n = obj->u.n;
    double z = obj->z;
    int width, height;
    int transparent;

    gvprintf(job, "# node %s\n", agnameof(n));
    if (z < MinZ)
	MinZ = z;
    if (shapeOf(n) != SH_POINT) {
	PNGfile = nodefile(job->output_filename, n);

	width  = (ND_lw(n) + ND_rw(n)) * Scale + 2 * NODE_PAD;
	height = (ND_ht(n)           ) * Scale + 2 * NODE_PAD;
	im = gdImageCreate(width, height);

	/* make background transparent */
	transparent = gdImageColorResolveAlpha(im,
                                           gdRedMax - 1, gdGreenMax,
                                           gdBlueMax, gdAlphaTransparent);
	gdImageColorTransparent(im, transparent);
    }
}