1
/* Copyright 2004,2007 ENSEIRB, INRIA & CNRS
3
** This file is part of the Scotch software package for static mapping,
4
** graph partitioning and sparse matrix ordering.
6
** This software is governed by the CeCILL-C license under French law
7
** and abiding by the rules of distribution of free software. You can
8
** use, modify and/or redistribute the software under the terms of the
9
** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
10
** URL: "http://www.cecill.info".
12
** As a counterpart to the access to the source code and rights to copy,
13
** modify and redistribute granted by the license, users are provided
14
** only with a limited warranty and the software's author, the holder of
15
** the economic rights, and the successive licensors have only limited
18
** In this respect, the user's attention is drawn to the risks associated
19
** with loading, using, modifying and/or developing or reproducing the
20
** software by the user in light of its specific status of free software,
21
** that may mean that it is complicated to manipulate, and that also
22
** therefore means that it is reserved for developers and experienced
23
** professionals having in-depth computer knowledge. Users are therefore
24
** encouraged to load and test the software's suitability as regards
25
** their requirements in conditions enabling the security of their
26
** systems and/or data to be ensured and, more generally, to use and
27
** operate it in the same conditions as regards security.
29
** The fact that you are presently reading this means that you have had
30
** knowledge of the CeCILL-C license and that you accept its terms.
32
/************************************************************/
34
/** NAME : graph.c **/
36
/** AUTHOR : Francois PELLEGRINI **/
38
/** FUNCTION : This module handles the source graph **/
41
/** DATES : # Version 0.0 : from : 01 dec 1992 **/
42
/** to 18 may 1993 **/
43
/** # Version 1.3 : from : 30 apr 1994 **/
44
/** to 18 may 1994 **/
45
/** # Version 2.0 : from : 06 jun 1994 **/
46
/** to 31 oct 1994 **/
47
/** # Version 3.0 : from : 07 jul 1995 **/
48
/** to 28 sep 1995 **/
49
/** # Version 3.1 : from : 28 nov 1995 **/
50
/** to 08 jun 1996 **/
51
/** # Version 3.2 : from : 07 sep 1996 **/
52
/** to 15 sep 1998 **/
53
/** # Version 3.3 : from : 22 sep 1998 **/
54
/** to 31 dec 1998 **/
55
/** # Version 4.0 : from : 24 nov 2001 **/
56
/** to 22 apr 2004 **/
58
/************************************************************/
61
** The defines and includes.
70
/****************************************/
72
/* These routines handle source graphs. */
74
/****************************************/
76
/* This routine initializes a source graph
79
** - 0 : in all cases.
84
Graph * const grafptr)
86
memSet (grafptr, 0, sizeof (Graph)); /* Initialize graph fields */
87
grafptr->flagval = GRAPHFREETABS; /* By default, free all arrays */
92
/* This routine frees a source graph structure.
94
** - VOID : in all cases.
99
Graph * const grafptr)
101
graphFree (grafptr); /* Free graph data */
103
#ifdef SCOTCH_DEBUG_GRAPH2
104
memSet (grafptr, ~0, sizeof (Graph)); /* Purge graph fields */
105
#endif /* SCOTCH_DEBUG_GRAPH2 */
108
/* This routine frees the graph data.
110
** - VOID : in all cases.
115
Graph * const grafptr)
117
if (((grafptr->flagval & GRAPHFREEEDGE) != 0) && /* If edgetab must be freed */
118
(grafptr->edgetax != NULL)) /* And if it exists */
119
memFree (grafptr->edgetax + grafptr->baseval); /* Free it */
121
if ((grafptr->flagval & GRAPHFREEVERT) != 0) { /* If verttab/vendtab must be freed */
122
if ((grafptr->vendtax != NULL) && /* If vendtax is distinct from verttab */
123
(grafptr->vendtax != grafptr->verttax + 1) && /* (if vertex arrays grouped, vendtab not distinct anyway) */
124
((grafptr->flagval & GRAPHVERTGROUP) == 0))
125
memFree (grafptr->vendtax + grafptr->baseval); /* Then free vendtax */
126
if (grafptr->verttax != NULL) /* Free verttab anyway, as it is the array group leader */
127
memFree (grafptr->verttax + grafptr->baseval);
129
if ((grafptr->flagval & GRAPHFREEVNUM) != 0) { /* If vnumtab must be freed */
130
if ((grafptr->vnumtax != NULL) && /* And is not in vertex array group */
131
((grafptr->flagval & GRAPHVERTGROUP) == 0))
132
memFree (grafptr->vnumtax + grafptr->baseval);
134
if ((grafptr->flagval & GRAPHFREEOTHR) != 0) { /* If other arrays must be freed */
135
if ((grafptr->velotax != NULL) && /* Free graph tables */
136
((grafptr->flagval & GRAPHVERTGROUP) == 0))
137
memFree (grafptr->velotax + grafptr->baseval);
138
if (grafptr->vlbltax != NULL)
139
memFree (grafptr->vlbltax + grafptr->baseval);
140
if ((grafptr->edlotax != NULL) &&
141
((grafptr->flagval & GRAPHEDGEGROUP) == 0))
142
memFree (grafptr->edlotax + grafptr->baseval);
145
#ifdef SCOTCH_DEBUG_GRAPH2
146
memSet (grafptr, ~0, sizeof (Graph)); /* Purge graph fields */
147
#endif /* SCOTCH_DEBUG_GRAPH2 */