Skip to content

ConflictColor is a Python tool for visualizing and solving graph coloring problems, ideal for planning university timetables. Define your events and conflicts in a simple JSON file, and the tool assigns colors to avoid overlaps. See your schedule as a clear, colored graph with just one command.

License

Notifications You must be signed in to change notification settings

schwarzfelix/ConflictColor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConflictColor

A graph coloring-based helper tool for planning timetables at university.

Features

  • Create and name nodes: Represent events, courses, or resources as nodes.
  • Create and name edges: Add edges between nodes with a comment describing the relationship or conflict (e.g., "overlap", "conflict").
  • Automatic graph coloring: The tool assigns colors to nodes so that no two connected nodes share the same color, minimizing the total number of colors used.
  • Visualization: Visualize the graph with colored nodes and labeled edges using matplotlib and networkx.
  • JSON input: Define your graph structure in a JSON file for easy editing and sharing.

Usage

  1. Install dependencies

    pip install -r requirements.txt
    
  2. Prepare your graph data
    Create a graph.json file in the project directory.
    Example:

    {
      "nodes": ["A", "B", "C"],
      "edges": [
        {"from": "A", "to": "B", "name": "A and B overlap"},
        {"from": "B", "to": "C", "name": "B and C conflict"},
        {"from": "A", "to": "C", "name": "A and C are related"}
      ]
    }

    You can also use the provided graph.json.example as a template.

  3. Run the program

    python app.py
    
  4. Example output
    The script prints the color assignment for each node and the number of colors used, and displays a visualization of the graph.

Example (programmatic usage)

g = Graph()
g.add_node("A")
g.add_node("B")
g.add_node("C")
g.add_edge("A", "B", "A and B overlap")
g.add_edge("B", "C", "B and C conflict")
g.add_edge("A", "C", "A and C are related")

coloring, num_colors = g.color_graph()
print("Coloring:", coloring)
print("Number of colors used:", num_colors)
g.visualize(coloring)

Requirements

  • Python 3.7+
  • matplotlib
  • networkx

License

MIT License

About

ConflictColor is a Python tool for visualizing and solving graph coloring problems, ideal for planning university timetables. Define your events and conflicts in a simple JSON file, and the tool assigns colors to avoid overlaps. See your schedule as a clear, colored graph with just one command.

Topics

Resources

License

Stars

Watchers

Forks

Languages