예제 #1
0
int
main ()
{
  printf ("Creating a directed graph: \n");
  graph_t graph = create_graph (V);

  add_edge (graph, 0, 1);
  add_edge (graph, 0, 4);
  add_edge (graph, 1, 2);
  add_edge (graph, 1, 3);
  add_edge (graph, 1, 4);
  add_edge (graph, 2, 3);
  add_edge (graph, 3, 4);
  add_edge (graph, 4, 0);
  add_edge (graph, 5, 0);
  add_edge (graph, 6, 0);

  display_graph (graph);

  printf ("Removing edges from vertix 1:\n");
  remove_edge (graph, 1, 2);
  remove_edge (graph, 1, 3);
  remove_edge (graph, 1, 4);

  display_graph (graph);
  destroy_graph (graph);

  return 0;
}
예제 #2
0
int main(){
  int num_vertices = 5;

  Graph* undir = create_graph(num_vertices, UNDIRECTED);
  Graph* dir = create_graph(num_vertices, DIRECTED);

  add_edge(undir,0,1);
  add_edge(undir,0,4);
  add_edge(undir,1,2);
  add_edge(undir,1,3);
  add_edge(undir,1,4);
  add_edge(undir,2,3);
  add_edge(undir,3,4);

  add_edge(dir,0,1);
  add_edge(dir,0,4);
  add_edge(dir,1,2);
  add_edge(dir,1,3);
  add_edge(dir,1,4);
  add_edge(dir,2,3);
  add_edge(dir,3,4);

  printf("\nUndirected Graph");
  display_graph(undir);

  printf("\nDirected Graph");
  display_graph(dir);

  return 0;
}
예제 #3
0
int
main ()
{
  printf ("Creating a directed graph: \n");
  graph_t *graph = create_graph (10, DIRECTED);
  add_edge (graph, 0, 2);
  add_edge (graph, 1, 6);
  add_edge (graph, 1, 5);
  add_edge (graph, 2, 1);
  add_edge (graph, 2, 3);
  add_edge (graph, 2, 4);
  add_edge (graph, 6, 7);
  add_edge (graph, 7, 8);
  add_edge (graph, 8, 9);

  display_graph (*graph);

  int c = 2, d = 1;
  printf ("%d and %d directly connected? %s\n", c, d, direct_connection (graph,
          c, d) ? "yes" : "no");
  c = 1, d = 7;
  printf ("%d and %d directly connected? %s\n", c, d, direct_connection (graph,
          c, d) ? "yes" : "no");

  c = 1, d = 7;
  printf ("%d and %d connected? %s\n", c, d, vertices_connected (graph,
          graph->list[c].head, &c, d) ? "yes" : "no");
  c = 1, d = 0;
  printf ("%d and %d connected? %s\n", c, d, vertices_connected (graph,
          graph->list[c].head, &c, d) ? "yes" : "no");

  return 0;
}
예제 #4
0
int main(){
	nd** G;
	int V,E,u,v;
	scanf("%d",&V);
	G = create_graph(V);
	scanf("%d",&E);
	while(E--){
		scanf("%d%d",&u,&v);
		add_edge(G,u,v);
	}	
	display_graph(G,V);
	degree(G,V);	
	return 0;
}
예제 #5
0
//--------------------------------------------------------------------------
// This callback handles various hexrays events.
static int idaapi callback(void *, hexrays_event_t event, va_list va)
{
  switch ( event )
  {
    case hxe_right_click:
      {
        vdui_t &vu = *va_arg(va, vdui_t *);
        // add new command to the popup menu
        add_custom_viewer_popup_item(vu.ct, "Display Graph", hotkey_dg, display_graph, &vu);
		add_custom_viewer_popup_item(vu.ct, "Object Explorer", hotkey_ce, display_objects, &vu);
		add_custom_viewer_popup_item(vu.ct, "REconstruct Type", hotkey_rt, reconstruct_type, &vu);
		add_custom_viewer_popup_item(vu.ct, "Jump to Disasm", hotkey_gd, decompiled_line_to_disasm, &vu);
      }
      break;

	case hxe_keyboard:
      {
        vdui_t &vu = *va_arg(va, vdui_t *);
        int keycode = va_arg(va, int);
        // check for the hotkey
		if (keycode == hotcode_dg)
          return display_graph(&vu);
		if (keycode == hotcode_ce)
			return display_objects(&vu);
		if (keycode == hotcode_rt)
          return reconstruct_type(&vu);
		if (keycode == hotcode_gd)
			return decompiled_line_to_disasm(&vu);
      }
      break;

	case hxe_double_click:
		{
			vdui_t &vu = *va_arg(va, vdui_t *);
			decompile_func(vu);
		}
		break;
    default:
      break;
  }
  return 0;
}