| 1 |
/** |
| 2 |
* @file |
| 3 |
* @brief support for connected components |
| 4 |
* @ingroup public_apis |
| 5 |
* |
| 6 |
* **libpack** supports the use of connected components |
| 7 |
* in the context of laying out graphs using other graphviz libraries. |
| 8 |
* One set of functions can be used to take a single graph and break it |
| 9 |
* apart into connected components. |
| 10 |
* A complementary set of functions takes a collection of graphs |
| 11 |
* (not necessarily components of a single graph) which have been laid |
| 12 |
* out separately, and packs them together. |
| 13 |
* |
| 14 |
* As this library is meant to be used with `libcommon`, it relies on the |
| 15 |
* @ref Agraphinfo_t, @ref Agnodeinfo_t and @ref Agedgeinfo_t used in |
| 16 |
* that library. |
| 17 |
* |
| 18 |
* [man 3 libpack](https://graphviz.org/pdf/pack.3.pdf) |
| 19 |
* |
| 20 |
*/ |
| 21 |
|
| 22 |
/************************************************************************* |
| 23 |
* Copyright (c) 2011 AT&T Intellectual Property |
| 24 |
* All rights reserved. This program and the accompanying materials |
| 25 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 26 |
* which accompanies this distribution, and is available at |
| 27 |
* https://www.eclipse.org/legal/epl-v10.html |
| 28 |
* |
| 29 |
* Contributors: Details at https://graphviz.org |
| 30 |
*************************************************************************/ |
| 31 |
|
| 32 |
#pragma once |
| 33 |
|
| 34 |
#include <stdbool.h> |
| 35 |
#include <stddef.h> |
| 36 |
|
| 37 |
#ifdef __cplusplus |
| 38 |
extern "C" { |
| 39 |
#endif |
| 40 |
|
| 41 |
#include "types.h" |
| 42 |
|
| 43 |
/* Type indicating granularity and method |
| 44 |
* l_undef - unspecified |
| 45 |
* l_node - polyomino using nodes and edges |
| 46 |
* l_clust - polyomino using nodes and edges and top-level clusters |
| 47 |
* (assumes ND_clust(n) unused by application) |
| 48 |
* l_graph - polyomino using computer graph bounding box |
| 49 |
* l_array - array based on graph bounding boxes |
| 50 |
* l_aspect - tiling based on graph bounding boxes preserving aspect ratio |
| 51 |
* l_hull - polyomino using convex hull (unimplemented) |
| 52 |
* l_tile - tiling using graph bounding box (unimplemented) |
| 53 |
* l_bisect - alternate bisection using graph bounding box (unimplemented) |
| 54 |
*/ |
| 55 |
typedef enum { l_undef, l_clust, l_node, l_graph, l_array, l_aspect } pack_mode; |
| 56 |
|
| 57 |
#define PK_COL_MAJOR (1 << 0) |
| 58 |
#define PK_USER_VALS (1 << 1) |
| 59 |
#define PK_LEFT_ALIGN (1 << 2) |
| 60 |
#define PK_RIGHT_ALIGN (1 << 3) |
| 61 |
#define PK_TOP_ALIGN (1 << 4) |
| 62 |
#define PK_BOT_ALIGN (1 << 5) |
| 63 |
#define PK_INPUT_ORDER (1 << 6) |
| 64 |
|
| 65 |
typedef unsigned int packval_t; |
| 66 |
|
| 67 |
typedef struct { |
| 68 |
float aspect; /* desired aspect ratio */ |
| 69 |
int sz; /* row/column size size */ |
| 70 |
unsigned int margin; /* margin left around objects, in points */ |
| 71 |
bool doSplines; ///< use splines in constructing graph shape |
| 72 |
pack_mode mode; /* granularity and method */ |
| 73 |
bool *fixed; /* fixed[i] == true implies g[i] should not be moved */ |
| 74 |
packval_t* vals; /* for arrays, sort numbers */ |
| 75 |
int flags; |
| 76 |
} pack_info; |
| 77 |
|
| 78 |
#ifdef GVDLL |
| 79 |
#ifdef GVC_EXPORTS |
| 80 |
#define PACK_API __declspec(dllexport) |
| 81 |
#else |
| 82 |
#define PACK_API __declspec(dllimport) |
| 83 |
#endif |
| 84 |
#endif |
| 85 |
|
| 86 |
#ifndef PACK_API |
| 87 |
#define PACK_API /* nothing */ |
| 88 |
#endif |
| 89 |
|
| 90 |
PACK_API pointf *putRects(size_t ng, boxf *bbs, pack_info *pinfo); |
| 91 |
PACK_API int packRects(size_t ng, boxf* bbs, pack_info* pinfo); |
| 92 |
|
| 93 |
PACK_API pointf *putGraphs(size_t, Agraph_t **, Agraph_t *, pack_info *); |
| 94 |
PACK_API int packGraphs(size_t, Agraph_t **, Agraph_t *, pack_info *); |
| 95 |
PACK_API int packSubgraphs(size_t, Agraph_t **, Agraph_t *, pack_info *); |
| 96 |
PACK_API int pack_graph(size_t ng, Agraph_t **gs, Agraph_t *root, bool *fixed); |
| 97 |
|
| 98 |
PACK_API int shiftGraphs(size_t, Agraph_t **, pointf *, Agraph_t *, bool); |
| 99 |
|
| 100 |
PACK_API pack_mode getPackMode(Agraph_t * g, pack_mode dflt); |
| 101 |
PACK_API int getPack(Agraph_t *, int not_def, int dflt); |
| 102 |
PACK_API pack_mode getPackInfo(Agraph_t * g, pack_mode dflt, int dfltMargin, pack_info*); |
| 103 |
PACK_API pack_mode getPackModeInfo(Agraph_t * g, pack_mode dflt, pack_info*); |
| 104 |
PACK_API pack_mode parsePackModeInfo(const char* p, pack_mode dflt, |
| 105 |
pack_info* pinfo); |
| 106 |
|
| 107 |
PACK_API int isConnected(Agraph_t *); |
| 108 |
PACK_API Agraph_t **ccomps(Agraph_t *, size_t *, char *); |
| 109 |
PACK_API Agraph_t **cccomps(Agraph_t *, size_t *, char *); |
| 110 |
PACK_API Agraph_t **pccomps(Agraph_t *, size_t *, char *, bool *); |
| 111 |
PACK_API Agraph_t *mapClust(Agraph_t *); |
| 112 |
#undef PACK_API |
| 113 |
#ifdef __cplusplus |
| 114 |
} |
| 115 |
#endif |