Skip to content

Examples

Bruno Silva edited this page Jun 9, 2025 · 3 revisions

The JavaFXSmartGraph repository includes a demonstration module that showcases various features of the library.

Examples

  • Location: com.brunomnsilva.smartgraph.examples.

    • cities.Main - Representation of city populations and distances;
    • digraph.Main - The main example illustrated in README (a digraph with directed edges);
    • dynamic.Main - Real-time visualization of model updates;
    • flowers.Main - Another example on a simple graph.
  • Running the Examples:

    1. Clone the repository: git clone https://github.com/brunomnsilva/JavaFXSmartGraph.git
    2. Navigate to the project directory: cd JavaFXSmartGraph
    3. Build the project (including the demo): mvn clean install
    4. Try to run one of the above classes. Must be executed as a standard JavaFX application.

Key Features Demonstrated

The demo applications typically illustrates:

  • Creation of graphs and digraphs.
  • Different vertex placement strategies (e.g., circular, random).
  • Automatic graph layout.
  • Interaction with vertices (dragging, selection).
  • Display of labels on vertices and edges.
  • Arrows for directed edges.
  • Self-loops and multiple edges.
  • Determining vertex shape and size, based on the underlying model.
  • Dynamic updates to the graph.
  • Basic styling.

Studying the Demo Code

The source code of the demo application (SmartGraphDemo.java or similar found in smartgraph-demo/src/main/java/...) is an excellent resource for learning how to use the library's features. It provides practical examples of:

  • Initializing SmartGraphPanel.
  • Using SmartGraphProperties.
  • Adding and removing graph elements dynamically.
  • Setting up event handlers (e.g., for double clicks).

By running the demo and examining its code, you can gain a deeper understanding of how to integrate JavaFXSmartGraph into your own applications.

Clone this wiki locally