当前位置: 首页>>代码示例>>C++>>正文


C++ print_graph函数代码示例

本文整理汇总了C++中print_graph函数的典型用法代码示例。如果您正苦于以下问题:C++ print_graph函数的具体用法?C++ print_graph怎么用?C++ print_graph使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了print_graph函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: print_graph

void print_graph(CELL* inicio)
{
    if(inicio->type.operador == '@')
    {
        if(inicio->left != NULL)
        {
            print_graph(inicio->left);
        }
        if(inicio->right != NULL)
        {
            if(inicio->right->type.operador == '@')
            {
                printf("(");
            }
            print_graph(inicio->right);
            if(inicio->right->type.operador == '@')
            {
                printf(")");
            }
        }
    }
    else if (inicio->id == 'o')
    {

        printf("%c",inicio->type.operador);
    }
    else if(inicio->id == 'n')
    {

        printf("%d", (int)inicio->type.number);
    }
}
开发者ID:newtonlb,项目名称:Compiladores,代码行数:32,代码来源:garbage.c

示例2: main

int main() {
    Node *root, *aux;
    int size, check = 1, number, temp, num1, num2;
    clock_t c2, c1;
    float _time;

    scanf("%s", input);
    transform_input();
    printf("(%s)\n", input);

    size = strlen(input);
    root = make_graph(0, size - 1);

    printf("Original Graph:\n");
    print_graph(root);
    printf("\n");

    printf("Start..\n");

    c1 = clock();
    root = reduce_graph(root, 0);
    c2 = clock();

    _time = (c2 - c1)*1000/CLOCKS_PER_SEC;

    printf("\n\nEnd!\n");
    printf("Reduced Graph:\n");
    print_graph(root);
    printf("\nTempo de redução: %dhs %dmin %dseg %dmiliseg\n\n", (((int) _time)/1000)/3600, ((((int) _time)/1000)%3600)/60, ((((int) _time)/1000)%3600)%60, ((int) _time) - (((int) _time)/1000)*1000);
    printf("\n");

    return 0;
}
开发者ID:victorcarrico,项目名称:compilers,代码行数:33,代码来源:_backend.c

示例3: main

int main(int argc, char* argv[]) {
  Adjacency_Matrix* g = (Adjacency_Matrix*) malloc(sizeof(Adjacency_Matrix));
  Adjacency_Matrix* tp;
  int* adjacency;
  empty_graph(g);

  int option, v, a1, a2;

  do {
    menu();
    scanf("%d", &option);
    switch (option) {
      case INSERT_VERTEX:
        printf("How many vertex would you like to insert? ");
        scanf("%d", &v);
        insert_vertex(g, v);
        break;
      case REMOVE_VERTEX:
        printf("Which vertex would you like to remove? ");
        scanf("%d", &v);
        remove_vertex(g, v);
        break;
      case INSERT_ARC:
        printf("First vertex: ");
        scanf("%d", &a1);
        printf("Second vertex: ");
        scanf("%d", &a2);
        insert_arc(g, a1, a2, 1);
        break;
      case REMOVE_ARC:
        printf("First vertex: ");
        scanf("%d", &a1);
        printf("Second vertex: ");
        scanf("%d", &a2);
        remove_arc(g, a1, a2);
        break;
      case VERTEX_ADJACENCY:
        printf("Which vertex would you like to verify adjacency?");
        scanf("%d", &v);
        adjacency = get_adjacency(g, v);
        print_adjacency(adjacency);
        free(adjacency);
        pause();
        break;
      case TRANSPOSE_GRAPH:
        tp = transpose_graph(g);
        print_graph(tp);
        free(tp);
        pause();
        break;
      case PRINT_GRAPH: 
        print_graph(g);
        pause();
        break;
    }
  } while (option != EXIT);

  return 0;
}
开发者ID:vitorfs,项目名称:graph,代码行数:59,代码来源:graph.c

示例4: interface_exit

//Exit screen
void interface_exit()
{
    screen_clear();
    screen_frame_create();
    print_graph("Are you sure you want to exit the program?",250,250);
    print_graph("Press 'Enter' to exit",320,266);
    SDL_RenderPresent(ren);
}
开发者ID:Stratholm,项目名称:PlotCalc,代码行数:9,代码来源:Graph_Funct.cpp

示例5: te_graph_trigger

gboolean
te_graph_trigger(gpointer user_data)
{
    enum transition_status graph_rc = -1;

    if (transition_graph == NULL) {
        crm_debug("Nothing to do");
        return TRUE;
    }

    crm_trace("Invoking graph %d in state %s", transition_graph->id, fsa_state2string(fsa_state));

    switch (fsa_state) {
        case S_STARTING:
        case S_PENDING:
        case S_NOT_DC:
        case S_HALT:
        case S_ILLEGAL:
        case S_STOPPING:
        case S_TERMINATE:
            return TRUE;
            break;
        default:
            break;
    }

    if (transition_graph->complete == FALSE) {
        int limit = transition_graph->batch_limit;

        transition_graph->batch_limit = throttle_get_total_job_limit(limit);
        graph_rc = run_graph(transition_graph);
        transition_graph->batch_limit = limit; /* Restore the configured value */

        print_graph(LOG_DEBUG_3, transition_graph);

        if (graph_rc == transition_active) {
            crm_trace("Transition not yet complete");
            return TRUE;

        } else if (graph_rc == transition_pending) {
            crm_trace("Transition not yet complete - no actions fired");
            return TRUE;
        }

        if (graph_rc != transition_complete) {
            crm_warn("Transition failed: %s", transition_status(graph_rc));
            print_graph(LOG_NOTICE, transition_graph);
        }
    }

    crm_debug("Transition %d is now complete", transition_graph->id);
    transition_graph->complete = TRUE;
    notify_crmd(transition_graph);

    return TRUE;
}
开发者ID:HyunKwangYong,项目名称:pacemaker,代码行数:56,代码来源:te_utils.c

示例6: te_graph_trigger

gboolean
te_graph_trigger(gpointer user_data)
{
    enum transition_status graph_rc = -1;

    if (transition_graph == NULL) {
        crm_debug("Nothing to do");
        return TRUE;
    }

    crm_debug_2("Invoking graph %d in state %s", transition_graph->id, fsa_state2string(fsa_state));

    switch (fsa_state) {
    case S_STARTING:
    case S_PENDING:
    case S_NOT_DC:
    case S_HALT:
    case S_ILLEGAL:
    case S_STOPPING:
    case S_TERMINATE:
        return TRUE;
        break;
    default:
        break;
    }

    if (transition_graph->complete == FALSE) {
        graph_rc = run_graph(transition_graph);
        print_graph(LOG_DEBUG_3, transition_graph);

        if (graph_rc == transition_active) {
            crm_debug_3("Transition not yet complete");
            return TRUE;

        } else if (graph_rc == transition_pending) {
            crm_debug_3("Transition not yet complete - no actions fired");
            return TRUE;
        }

        if (graph_rc != transition_complete) {
            crm_err("Transition failed: %s", transition_status(graph_rc));
            print_graph(LOG_WARNING, transition_graph);
        }
    }

    crm_info("Transition %d is now complete", transition_graph->id);
    transition_graph->complete = TRUE;
    notify_crmd(transition_graph);

    return TRUE;
}
开发者ID:huiser,项目名称:pacemaker,代码行数:51,代码来源:te_utils.c

示例7: main

int main()
{
    // named vertices
    auto const A = V { 1 };
    auto const B = V { 2 };

    // construct the graph
    auto e = std::vector<E> { { A, 3 }, { B, 4 } };
    auto g = G { std::begin(e), std::end(e), 4 };

    print_graph(g);
    collapse_vertices(B, A, g);
    print_graph(g);
}
开发者ID:CCJY,项目名称:coliru,代码行数:14,代码来源:main.cpp

示例8: main

main()
{
  int G[20][20],no_of_nodes,mst[20][20];

  printf("Enter no.of nodes:");
  scanf("%d",&no_of_nodes);
  create_graph(G,no_of_nodes);
  printf("---Original graph---\n");
  print_graph(G,no_of_nodes);

  MST_kruskal(G,no_of_nodes,mst);
  printf("----Mst---\n");
  print_graph(mst,no_of_nodes);
}
开发者ID:abilng,项目名称:Kerala-University-B.TECH-LAB,代码行数:14,代码来源:KruskalMST.c

示例9: unitTestDfs

void unitTestDfs() {
    {
        Graph g(5, false);
        print_graph(g);
        g.insert(1, 2);
        print_graph(g);

        g.insert(1, 3);
        print_graph(g);

        g.insert(1, 4);
        print_graph(g);

        
        g.insert(2, 3);
        print_graph(g);

        
        g.insert(3, 5);
        print_graph(g);

        
        g.insert(4, 1);
        print_graph(g);

        
        g.insert(5, 2);
        print_graph(g);

        
        dfs(g, 1);
    }
}
开发者ID:peanut-buttermilk,项目名称:fun-run,代码行数:33,代码来源:dfs_algos.cpp

示例10: main

int main(int argc,char *argv[])
{
  read_graph(argv[1]);

  printf("Main print\n");
  print_graph();

  
  int smallestOutDegree = smallestOutDegreeSearch(getAllNodeIndexs());
  char *name = mygraph->table[smallestOutDegree].name;
  
  int largestOutDegree = largestOutDegreeSearch(getAllNodeIndexs());
  char *name1 = mygraph->table[largestOutDegree].name;

  
  int smallestInDegree = smallestInDegreeSearch(getAllNodeIndexs());
  char *name2 = mygraph->table[smallestInDegree].name;
  
  int largestInDegree = largestInDegreeSearch(getAllNodeIndexs());
  char *name3 = mygraph->table[largestInDegree].name;
  
  printf("The smallest outdegree: %d \t Name: %s(%dth)\n"
         , mygraph->table[smallestOutDegree].outdegree, name, smallestOutDegree);
  printf("The largest outdegree: %d \t Name: %s(%dth)\n\n"
         , mygraph->table[largestOutDegree].outdegree , name1, largestOutDegree);
  
  printf("The smallest indegree: %d \t Name: %s(%dth)\n"
         , mygraph->table[smallestInDegree].indegree  , name2, smallestInDegree);
  printf("The largest  indegree: %d \t Name: %s(%dth)\n"
         , mygraph->table[largestInDegree].indegree   , name3, largestInDegree );
  
  return(0);
}//main
开发者ID:ZhihuiYe,项目名称:C-code,代码行数:33,代码来源:2+graph+degree+search+algs.c

示例11: main

void main(){
	Graph *G;
	G = (Graph *)malloc(sizeof(Graph));
	printf("Enter the number of nodes :");
	scanf("%d", &(G->v));
	G->arr = (AdjList *)malloc(((G->v) + 1)*sizeof(AdjList));
	int i;
	for(i = 1; i <= (G->v); i++)
		(G->arr[i]).head = NULL;
	printf("Enter '1 2' for an edge between nodes 1 and 2\n");
	printf("Enter '0 0' to exit\n");
	for(;;)
	{
		printf("Enter the edges\n");
		int n1, n2;
		scanf ("%d %d", &n1, &n2);
		if((n1 <= (G->v) && n1 > 0) && (n2 <= (G->v) && n2 > 0))
			G = addEdge(G, n1, n2);
		else
		{	printf("Input Stop\n");
			break;
		}
	}
	print_graph(G);
	DFS(G);
	dfs_check(G);
}	
开发者ID:kshitij10496,项目名称:Algorithms,代码行数:27,代码来源:dfs_recursion.c

示例12: main

int main()
{
    graph g;
    read_graph(&g, 0);
    dijkstra(&g, 0);
    print_graph(&g);
}
开发者ID:johnreed816,项目名称:randomscripts,代码行数:7,代码来源:dijkstra.c

示例13: main

int main(int argc, char *argv[])
{
	FILE *f;
	char buf[LINE];
	int n = 0;
	int n1, n2;
	
	srand(time(NULL));
	f = fopen(argv[1], "r");
	if (f == NULL)
		return errno;
	while (fgets(buf, LINE, f)) {
		load_node(buf, &nodes[n]);
		n++;
	}
	fclose(f);
	max_nodes = num_nodes = n;

	while (num_nodes > 2) {
		pick_edge(&n1, &n2);
		merge_nodes(n1, n2);
	}

	print_graph();

	return 0;
}
开发者ID:hkoehler,项目名称:LeetCode,代码行数:27,代码来源:mincut.c

示例14: handle_discover_response

void handle_discover_response(pkt_t *pkt)
{
    node_id_t origin = pkt->payload[PKT_RESPONSE_ORIGIN_OFFSET];
    uint8_t seq = pkt->payload[PKT_RESPONSE_SEQ_OFFSET];
    nrk_time_t delay;
    uint8_t attempt;

    if (!IS_VALID_NODE_ID(origin)) {
        LOG("WARN: invalid origin in response: ");
        LOGP("%d\r\n", origin);
        return;
    }

    LOG("response: orig "); LOGP("%u", origin);
    LOGA(" seq "); LOGP("%u", seq);
    LOGA(" src "); LOGP("%u", pkt->src);
    LOGA(": ");

    nrk_time_get(&last_activity);

    if (origin == this_node_id) {
        LOGA("reached origin\r\n");

        add_path_to_graph(pkt);
        print_graph(&network);
    } else { /* we're not the destination: forward to gateway */
        attempt = 0;
        do {
            forward_response(pkt, attempt);
            choose_delay(&delay, &discover_req_delay);
            nrk_wait(delay);
        } while (++attempt < discover_send_attempts);
    }
}
开发者ID:nishantP-10,项目名称:WSNS15IRFence,代码行数:34,代码来源:rftop.c

示例15: test_chaitin_spill

// 1 color a 3 node, 2 edge graph
// the node with the most edges should be spilled
void test_chaitin_spill() {
    DEBUG_PRINT("\ntest_chaitin_spill:\n");
    DEBUG_PRINT("  creating graph...\n");

    graph* g = create_graph();

    vertex* a = graph_add_vertex(g, 'a');
    vertex* b = graph_add_vertex(g, 'b');
    vertex* c = graph_add_vertex(g, 'c');

    graph_add_edge(a, b);
    graph_add_edge(a, c);
    
    assert(a->color == -1);
    assert(b->color == -1);
    assert(c->color == -1);

    DEBUG_PRINT("  coloring graph...\n");

    color_graph(g, 1);

    #ifdef DEBUG
    print_graph(g);
    #endif

    assert(a->color == -1); // spilled node
    assert(b->color == 0);
    assert(c->color == 0);

    destroy_graph(g);

    printf("+ algorithm test (spill) passed!\n");
}
开发者ID:kdef,项目名称:chachachaitin,代码行数:35,代码来源:test.c


注:本文中的print_graph函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。