项目作者: benedekrozemberczki

项目描述 :
A generator for unit disk graphs conditioned on concave hull cover.
高级语言: Python
项目地址: git://github.com/benedekrozemberczki/HullCoverConditionedUnitDiskGraph.git
创建时间: 2018-12-04T14:33:49Z
项目社区:https://github.com/benedekrozemberczki/HullCoverConditionedUnitDiskGraph

开源协议:GNU General Public License v3.0

下载


Hull Cover Conditioned Unit Disk Graph

codebeat badge repo sizebenedekrozemberczki


A generator for unit disk graphs conditioned on hull cover. The model first generates uniformly distributed points in 2 dimensions. Based on the input image points which are not covered with black (conditioning) are deleted from the initial set of points. Using the remaining point a fixed r-radius unit disk graph is grown. Finally, the edge list of the graph is saved with a large resolution plot of the graph.




### Requirements

The codebase is implemented in Python 3.5.2. package versions used for development are just below.
networkx 2.4 pandas 0.23.4 argparse 1.1.0 imageio 2.4.1 matplotlib 2.2.2
### Datasets


The code takes an input black and white jpeg file. Every pixel indicates whether the data point generated randomly is covered by black in the image or not. Points without a cover are dropped. The /input/ folder contains a Mickey Mouse head, a T-rex and a flower as an example input image.


Options

Learning of the embedding is handled by the src/main.py script which provides the following command line arguments.

Input and output options

  1. --input-path STR Input image path. Default is `input/trex.jpg`.
  2. --output-image STR Output image path. Default is `output/edges/trex_edges.csv`.
  3. --output-edges STR Edge list path. Default is `output/plot/trex_graph.png`.

Model options

  1. --node-color STR Node coloring in plot. Default is `green`.
  2. --point-number INT Number of points in space. Default is 10,000.
  3. --dpi INT DPI of plot. Default is 500.
  4. --radius FLOAT Radius for graph generation. Default is 0.04.
  5. --line-width FLOAT Line width. Default is 0.2.
  6. --alpha FLOAT Alpha for color strength. Default is 0.3.
  7. --node-size FLOAT Node size in plot. Default is 12.0.

Examples

The following commands learn a graph embedding and write the embedding to disk. The node representations are ordered by the ID.

Creating a random graph from the default T-rex image.

  1. python src/main.py

Creating an random graph from the flower image. The graph generation and plotting parameters are changed to create a high quality result.

  1. python src/main.py --input-path input/flower.jpeg --output-image output/plot/flower.png --output-edges output/edges/flower.edges --node-color "red" --radius 0.07 --alpha 0.5

License