Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7857461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:03:10+00:00 2026-06-02T21:03:10+00:00

The next code uses igraph_neighborhood, and it runs good, i don’t know why i

  • 0

The next code uses igraph_neighborhood, and it runs good, i don’t know why i get

#include <igraph.h>
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <algorithm>



void print_vector(igraph_vector_t *v, FILE *f) {
  long int i;
  for (i=0; i<igraph_vector_size(v); i++) {
    fprintf(f, " %li", (long int) VECTOR(*v)[i]);
  }
  fprintf(f, "\n");
}

using namespace std;

int main() {

  igraph_t g;
  igraph_vector_t v;


  igraph_vector_init(&v,32);
  VECTOR(v)[0]=0; VECTOR(v)[1]=1;
  VECTOR(v)[2]=0; VECTOR(v)[3]=4;
  VECTOR(v)[4]=0; VECTOR(v)[5]=9;
  VECTOR(v)[6]=1; VECTOR(v)[7]=7;
  VECTOR(v)[8]=1; VECTOR(v)[9]=9;
  VECTOR(v)[10]=2; VECTOR(v)[11]=9;
  VECTOR(v)[12]=2; VECTOR(v)[13]=3;
  VECTOR(v)[14]=2; VECTOR(v)[15]=5;
  VECTOR(v)[16]=3; VECTOR(v)[17]=6;
  VECTOR(v)[18]=3; VECTOR(v)[19]=9;
  VECTOR(v)[20]=4; VECTOR(v)[21]=5;
  VECTOR(v)[22]=4; VECTOR(v)[23]=8;
  VECTOR(v)[24]=5; VECTOR(v)[25]=8;
  VECTOR(v)[26]=6; VECTOR(v)[27]=7;
  VECTOR(v)[28]=6; VECTOR(v)[29]=8;
  VECTOR(v)[30]=7; VECTOR(v)[31]=8;

  igraph_create(&g, &v, 0,0);

  // Cycle 1
  igraph_vector_ptr_t vn1;
  igraph_vs_t vs;
  long int i;

  igraph_vector_ptr_init(&vn1, 10);
  for (i=0; i<igraph_vector_ptr_size(&vn1); i++) {
    VECTOR(vn1)[i] = calloc(1, sizeof(igraph_vector_t));
    igraph_vector_init((igraph_vector_t *)VECTOR(vn1)[i], 0);
  }

  igraph_vs_vector_small(&vs, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1);
  igraph_neighborhood(&g, &vn1,vs, 1, IGRAPH_OUT);

  for (i=0; i<igraph_vector_ptr_size(&vn1); i++) {
    print_vector((igraph_vector_t *)VECTOR(vn1)[i],stdout);
    igraph_vector_destroy((igraph_vector_t *)VECTOR(vn1)[i]);
    free((igraph_vector_t *)VECTOR(vn1)[i]);
  } 

  igraph_vector_ptr_destroy(&vn1);
  igraph_vs_destroy(&vs);
  igraph_destroy(&g);

  if (!IGRAPH_FINALLY_STACK_EMPTY) return 1;

  return 0;
}

it runs good, but i have the next output Valgrind:
it runs good, but i have the next output Valgrind:
it runs good, but i have the next output Valgrind:

 ==13517== Memcheck, a memory error detector
==13517== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==13517== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==13517== Command: ./example
==13517== 
--13517-- Valgrind options:
--13517--    --suppressions=/usr/lib/valgrind/debian-libc6-dbg.supp
--13517--    --leak-check=full
--13517--    -v
--13517-- Contents of /proc/version:
--13517--   Linux version 2.6.32-35-generic-pae (buildd@vernadsky) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #78-Ubuntu SMP Tue Oct 11 17:01:12 UTC 2011
--13517-- Arch and hwcaps: X86, x86-sse1-sse2
--13517-- Page sizes: currently 4096, max supported 4096
--13517-- Valgrind library directory: /usr/lib/valgrind
--13517-- Reading syms from /lib/ld-2.11.1.so (0x4000000)
--13517-- Reading debug info from /lib/ld-2.11.1.so ..
--13517-- .. CRC mismatch (computed 45f50ae1 wanted 137bc614)
--13517-- Reading debug info from /usr/lib/debug/lib/ld-2.11.1.so ..
--13517-- Reading syms from /home/rvaca/workSpalceIgraphCpp/proyIgraph/example (0x8048000)
--13517-- Reading syms from /usr/lib/valgrind/memcheck-x86-linux (0x38000000)
--13517--    object doesn't have a dynamic symbol table
--13517-- Reading suppressions file: /usr/lib/valgrind/debian-libc6-dbg.supp
--13517-- Reading suppressions file: /usr/lib/valgrind/default.supp
--13517-- REDIR: 0x40160b0 (index) redirected to 0x3803e9b3 (vgPlain_x86_linux_REDIR_FOR_index)
--13517-- Reading syms from /usr/lib/valgrind/vgpreload_core-x86-linux.so (0x401f000)
--13517-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so (0x4022000)
==13517== WARNING: new redirection conflicts with existing -- ignoring it
--13517--     new: 0x040160b0 (index               ) R-> 0x04025c30 index
--13517-- REDIR: 0x4016290 (strlen) redirected to 0x4026070 (strlen)
--13517-- Reading syms from /usr/local/lib/libigraph.so.0.0.0 (0x402b000)
--13517-- Reading syms from /usr/lib/libstdc++.so.6.0.13 (0x4213000)
--13517--    object doesn't have a symbol table
--13517-- Reading syms from /lib/tls/i686/cmov/libm-2.11.1.so (0x4308000)
--13517-- Reading debug info from /lib/tls/i686/cmov/libm-2.11.1.so ..
--13517-- .. CRC mismatch (computed a765a73c wanted 8d13be57)
--13517-- Reading debug info from /usr/lib/debug/lib/tls/i686/cmov/libm-2.11.1.so ..
--13517-- Reading syms from /lib/libgcc_s.so.1 (0x432e000)
--13517-- Reading debug info from /lib/libgcc_s.so.1 ..
--13517-- .. CRC mismatch (computed 338494ad wanted b1d69d39)
--13517--    object doesn't have a symbol table
--13517-- Reading syms from /lib/tls/i686/cmov/libc-2.11.1.so (0x434d000)
--13517-- Reading debug info from /lib/tls/i686/cmov/libc-2.11.1.so ..
--13517-- .. CRC mismatch (computed 2236eb0a wanted a071c0c3)
--13517-- Reading debug info from /usr/lib/debug/lib/tls/i686/cmov/libc-2.11.1.so ..
--13517-- Reading syms from /usr/lib/libxml2.so.2.7.6 (0x44a8000)
--13517-- Reading debug info from /usr/lib/libxml2.so.2.7.6 ..
--13517-- .. CRC mismatch (computed 8c0a5cb7 wanted d9f96831)
--13517--    object doesn't have a symbol table
--13517-- Reading syms from /usr/lib/libgmp.so.3.5.2 (0x45d3000)
--13517-- Reading debug info from /usr/lib/libgmp.so.3.5.2 ..
--13517-- .. CRC mismatch (computed b9cf7786 wanted 4db0a849)
--13517--    object doesn't have a symbol table
--13517-- Reading syms from /lib/tls/i686/cmov/libdl-2.11.1.so (0x4634000)
--13517-- Reading debug info from /lib/tls/i686/cmov/libdl-2.11.1.so ..
--13517-- .. CRC mismatch (computed 10f03463 wanted f15a6db6)
--13517-- Reading debug info from /usr/lib/debug/lib/tls/i686/cmov/libdl-2.11.1.so ..
--13517-- Reading syms from /lib/libz.so.1.2.3.3 (0x4638000)
--13517-- Reading debug info from /lib/libz.so.1.2.3.3 ..
--13517-- .. CRC mismatch (computed 53909dc3 wanted dc0e37c9)
--13517--    object doesn't have a symbol table
--13517-- REDIR: 0x43c0b10 (rindex) redirected to 0x4025ae0 (rindex)
--13517-- REDIR: 0x43c07f0 (__GI_strlen) redirected to 0x4026050 (__GI_strlen)
--13517-- REDIR: 0x43bc660 (calloc) redirected to 0x402417f (calloc)
--13517-- REDIR: 0x43bdec0 (realloc) redirected to 0x4024f4a (realloc)
--13517-- REDIR: 0x43c1930 (memset) redirected to 0x401f44c (_vgnU_ifunc_wrapper)
--13517-- REDIR: 0x445bef0 (__memset_sse2) redirected to 0x4027420 (memset)
--13517-- REDIR: 0x43bce60 (free) redirected to 0x4024ab5 (free)
--13517-- REDIR: 0x43c1f20 (memcpy) redirected to 0x401f44c (_vgnU_ifunc_wrapper)
--13517-- REDIR: 0x445d000 (__memcpy_ssse3) redirected to 0x40267f0 (memcpy)
--13517-- REDIR: 0x43c32b0 (strchrnul) redirected to 0x4027510 (strchrnul)
 0 1 4 9
 1 0 7 9
 2 3 5 9
 3 2 6 9
 4 0 5 8
 5 2 4 8
 6 3 7 8
 7 1 6 8
 8 4 5 6 7
 9 0 1 2 3
==13517== 
==13517== HEAP SUMMARY:
==13517==     in use at exit: 456 bytes in 21 blocks
==13517==   total heap usage: 73 allocs, 52 frees, 3,428 bytes allocated
==13517== 
==13517== Searching for pointers to 21 not-freed blocks
==13517== Checked 425,428 bytes
==13517== 
==13517== 200 (120 direct, 80 indirect) bytes in 10 blocks are definitely lost in loss record 2 of 3
==13517==    at 0x402425F: calloc (vg_replace_malloc.c:467)
==13517==    by 0x8048DF7: main (startdIII.cpp:76)
==13517== 
==13517== 256 bytes in 1 blocks are definitely lost in loss record 3 of 3
==13517==    at 0x402425F: calloc (vg_replace_malloc.c:467)
==13517==    by 0x40C9A78: igraph_vector_init (vector.pmt:123)
==13517==    by 0x8048B43: main (startdIII.cpp:49)
==13517== 
==13517== LEAK SUMMARY:
==13517==    definitely lost: 376 bytes in 11 blocks
==13517==    indirectly lost: 80 bytes in 10 blocks
==13517==      possibly lost: 0 bytes in 0 blocks
==13517==    still reachable: 0 bytes in 0 blocks
==13517==         suppressed: 0 bytes in 0 blocks
==13517== 
==13517== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 27 from 6)
--13517-- 
--13517-- used_suppression:     27 dl-hack3-cond-1
==13517== 
==13517== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 27 from 6)

What’s wrong? I’ve been trying differents way but it continue with the same output.

Thank advance

vacing

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:03:11+00:00Added an answer on June 2, 2026 at 9:03 pm
    1. Your vector v is never destroyed – that’s why you got the second warning in Valgrind.

    2. You must pass an initialized but empty igraph_vector_ptr_t into igraph_neighborhood, otherwise it will simply get rid of the pointers (and the vectors) already in there and allocate new ones. This is because igraph_neighborhood does not know how the pointers in igraph_vector_ptr_t were allocated and what destructor should be called on them (if any), so it tries to do the least damage and simply ignore them. So, no need to pre-load your igraph_vector_ptr_t with vectors in the first for loop. This gets rid of the first warning.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The next code runs normally in SQLSERVER but when i change the web.config to
I was trying the next code without success HTML <a id=addBookButton href=javascript:showForm('addBookButton','add-book','activateAddBookForm'); class=addA><span>Add Book</span></a>
I have the next code in javascript. I deleted some unnecessary items because it
I have the next code: Process p = Runtime.getRuntime().exec(args); and I want my program
I use next code to print current time Calendar cal = Calendar.getInstance(); System.out.println(cal.getTime()); I
I have the next code that was given to me to split up a
I have a next code in my view: <% @todos.each do |todo| %> <tr>
I have next code require 'rack/rpc' class Server < Rack::RPC::Server def hello_world Hello, world!
I have the next code: js: $('[id^=check-]').change(function(){ var new_id = this.id.replace(/check/, 'new'), real_id =
In the next code: section .data sa db ’abxdefghxl’,0 la EQU $ - sa

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.