Thread: Help with strange error

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    2

    Help with strange error

    Hi guyz,

    I'm working with a brute force algorithm for graph coloring...

    But, there is something that is blowing my mind.

    In general, my code works.

    My trouble lies with the follow error:

    When my graph has less than 7 (excluded) nodes, everything goes well.

    But for 7 or more, this happens:

    Example1:
    Code:
    Graph with 7 nodes:
    Node 0: 1
    Node 1: 2
    Node 2: 3
    Node 3: 4
    Node 4: 2
    Node 5: 3
    Node 6: 7
    Example 2:

    Code:
    Graph with 70 nodes:
    Node 0: 1
    Node 1: 2
    Node 2: 3
    Node 3: 4
    Node 4: 2
    Node 5: 3
    Node 6: 70
    Node 7: 1
    Node 8: 2
    ...
    Node 69: 1
    For all situations, it works well for all nodes, except for 6th, who gets the number of nodes of graph!

    My code is in portugues, but i think that you can understand it easy.

    EDIT: The problem was with the dynamic allocation of the array that recieves the node's color.
    Last edited by fabriciomind; 06-03-2011 at 06:30 AM. Reason: Remove code, and post the solution.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You overestimate my Portuguese, trust me.

    Why not just set a watch so your debugger will stop when node 6's value changes to equal the number of nodes? In 10 seconds, you'll know just where the error is occurring.

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    2
    haaaaaaaaaaa

    Apparently the error was with allocation of the array who recieves the colors.

    I did some changes and it worked like a charm!

    About using a debugger, I really need to take a time to study how to use gdb.

    Ty Adak! Next time I promise that I'll post the code in english!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange Error. . .
    By Kennedy in forum C Programming
    Replies: 6
    Last Post: 08-14-2009, 04:39 PM
  2. Strange error
    By Ideswa in forum C++ Programming
    Replies: 8
    Last Post: 03-05-2006, 06:10 AM
  3. Strange error
    By 182 in forum C++ Programming
    Replies: 1
    Last Post: 02-15-2006, 06:07 PM
  4. Strange error
    By egomaster69 in forum C Programming
    Replies: 2
    Last Post: 12-02-2004, 02:14 AM
  5. Strange C++ error ...
    By MadGooseXP in forum C++ Programming
    Replies: 2
    Last Post: 03-23-2002, 02:45 PM