SNUCSE-CTA/GI

Coding Convention

gmgu opened this issue · 1 comments

gmgu commented

We need a coding convention in some parts of our source code.

  • I recommend to avoid prefix or postfix operator inside an array or a function.
    For example, avoid the following command.

    splitCell[numSplitCell++] = c;

    Instead, I recommend to split it into two lines as follows.
    splitCell[numSplitCell] = c;
    ++numSplitCell

  • I recommend to add a single blank line between each logical blocks.
    For example, consider the following code.

    memset(markCell, 0, sizeof(long long)*numNode);

    It can be rewritten like
    memset(markCell, 0, sizeof(long long) * numNode);

  • I recommend to state a command in the next line of its conditional statement (not in the same line).
    For example,

    if (coloring->numCell == numNode) break;

    I think it is better to place break; under the if statement.

I just skimmed the source code, so there can be more issues about the coding convention.
Perhaps we can write a document of the coding convention and update it as we develop this project...

gmgu commented
  • We need to write a file header for each file.
    For example,
//***************************************************************************
// This file is part of the graph isomorphism algorithm.
// Copyright by Geonmo Gu, Yehyun Nam, and Kunsoo Park
// 
// Name: backtrack.cpp
// Author: Geonmo Gu
// Version
//     August 20, 2020: the first stable version. (version 1.0)
//***************************************************************************
  • Also, we need to write comments for each function
  1. In a '.cpp' file,
//SEARCH for an embedding of aG1 in aG2
//RETURN true if there is an embedding, false otherwise
bool Backtrack::run(Coloring* aColoring, Graph* aG1, Graph* aG2, int32_t aNumTreeNode)
  1. In a '.h' file
//parameters: [stable coloring of aG1], [aG1], [aG2], [the number of tree nodes in aG1]
//SEARCH for an embedding of aG1 in aG2
//RETURN true if there is an embedding, false otherwise
bool run(Coloring*, Graph*, Graph*, int32_t);