Graphviz  2.29.20120524.0446
lib/neatogen/sparsegraph.h
Go to the documentation of this file.
00001 /* $Id$ $Revision$ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /*************************************************************************
00005  * Copyright (c) 2011 AT&T Intellectual Property 
00006  * All rights reserved. This program and the accompanying materials
00007  * are made available under the terms of the Eclipse Public License v1.0
00008  * which accompanies this distribution, and is available at
00009  * http://www.eclipse.org/legal/epl-v10.html
00010  *
00011  * Contributors: See CVS logs. Details at http://www.graphviz.org/
00012  *************************************************************************/
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 #ifndef SPARSEGRAPH_H
00019 #define SPARSEGRAPH_H
00020 
00021 #ifdef HAVE_CONFIG_H
00022 #  include <config.h>
00023 #endif
00024 
00025 #ifdef __cplusplus
00026     enum Style { regular, invisible };
00027     struct vtx_data {
00028         int nedges;
00029         int *edges;
00030         float *ewgts;
00031         Style *styles;
00032         float *edists; /* directed dist reflecting the direction of the edge */
00033     };
00034 
00035     typedef int DistType;       /* must be signed!! */
00036 #if 0
00037     inline double max(double x, double y) {
00038         if (x >= y)
00039             return x;
00040         else
00041             return y;
00042     } inline double min(double x, double y) {
00043         if (x <= y)
00044             return x;
00045         else
00046             return y;
00047     }
00048 
00049     inline int max(int x, int y) {
00050         if (x >= y)
00051             return x;
00052         else
00053             return y;
00054     }
00055 
00056     inline int min(int x, int y) {
00057         if (x <= y)
00058             return x;
00059         else
00060             return y;
00061     }
00062 #endif
00063 
00064     struct Point {
00065         double x;
00066         double y;
00067         int operator==(Point other) {
00068             return x == other.x && y == other.y;
00069     }};
00070 #else
00071 
00072 #ifdef USE_STYLES
00073     typedef enum { regular, invisible } Style;
00074 #endif
00075     typedef struct {
00076         int nedges;             /* no. of neighbors, including self */
00077         int *edges;             /* edges[0..(nedges-1)] are neighbors; edges[0] is self */
00078         float *ewgts;           /* preferred edge lengths */
00079     } v_data; 
00080 
00081     typedef struct {
00082         int nedges;             /* no. of neighbors, including self */
00083         int *edges;             /* edges[0..(nedges-1)] are neighbors; edges[0] is self */
00084         float *ewgts;           /* preferred edge lengths */
00085         float *eweights;        /* edge weights */
00086 #ifdef USE_STYLES
00087         Style *styles;
00088 #endif
00089 #ifdef DIGCOLA
00090         float *edists; /* directed dist reflecting the direction of the edge */
00091 #endif
00092     } vtx_data;
00093 
00094     typedef int DistType;       /* must be signed!! */
00095 
00096 extern void freeGraphData(vtx_data * graph);
00097 extern void freeGraph(v_data * graph);
00098 
00099 #endif
00100 
00101 #endif
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif