manim-weighted-line


Namemanim-weighted-line JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/mutable-learning/manim-weighted-line
SummaryAdds a weighted line object to use with network graph diagrams.
upload_time2023-07-17 10:12:51
maintainer
docs_urlNone
authorMutableLearning
requires_python>=3.8,<3.12
licenseMIT
keywords manim plugins
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Manim Weighted Line
A plugin for creating weighted network graphs in Manim

## Table of contents:
- [Manim Weighted Line](#manim-weighted-line)
  - [Table of contents:](#table-of-contents)
  - [Installation.](#installation)
  - [What does Manim-Weighted-Line do?](#what-does-manim-weighted-line-do)
  - [How do I use Manim-Weighted-Line?](#how-do-i-use-manim-weighted-line)
  - [Take a look at the examples](#take-a-look-at-the-examples)
  - [How to contact](#how-to-contact)

## Installation.

You can install via pip:

```
pip install manim-weighted-line
```

You can also clone the repo and install it from here:

```
git clone https://github.com/mutable-learning/manim-weighted-line.git
cd manim-weighted-line
python -m pip install .
```

or

```
git clone https://github.com/mutable-learning/manim-weighted-line.git
cd manim-weighted-line 
python -m pip install -e .
```


## What does Manim-Weighted-Line do?
This is a simple plugin that is designed to meet the needs of manim users who want to
 create weighted network graphs in Manim. There is no easy way to add weightings to
 the edges of graphs in Manim, so this plugin provides a simple solution for both 
 undirected and directed graphs.

## How do I use Manim-Weighted-Line?
After installing the plugin, you can start using it by running:


```
from manim import *
from manim_weighted_line import *

```
for example

```
from manim import *
from manim_weighted_line import *

class SimpleExample(Scene):
    def construct(self):
        weighted_line = WeightedLine(
            0,
            1,
            weight=4,
        )
        self.add(weighted_line)
```
and we get

![Simple Example](examples/examples_assets/SimpleExample_ManimCE_v0.17.3.png)

To use this line in your graphs, pass the configuration to the edge object and use the WeightedLine as the edge_type.

```
from manim import *
from manim_weighted_line import *

class WeightedGraph(Scene):
    def construct(self):
        vertices = [1, 2, 3, 4, 5, 6, 7, 8]
        edges = [(1, 7), (1, 8), (2, 3), (2, 4), (2, 5),
                 (2, 8), (3, 4), (6, 1), (6, 2),
                 (6, 3), (7, 2), (7, 4)]
        g = DiGraph(vertices, edges, layout="circular", layout_scale=3,
                  labels=True, vertex_config={7: {"fill_color": RED}},
                  edge_type=WeightedLine,
                  edge_config={(1, 7): {"stroke_color": RED, 'weight': 2},
                               (7, 2): {"stroke_color": RED, 'weight': 0},
                               (7, 4): {"stroke_color": RED, 'weight': 5}})
        self.add(g)
```

and we get

![Weighted Graph](examples/examples_assets/WeightedGraph_ManimCE_v0.17.3.png)

If you are using NetworkX to create your graph, you can use the WeightedLine as the edge_type and pass it config options in the edge_config dictionary:

```
from manim import *
from manim_weighted_line import *
import networkx as nx

class NetworkXGraph(Scene):
    def construct(self):
        G = nx.Graph()
        G.add_nodes_from([1, 2, 3, 4, 5, 6, 7, 8])
        G.add_weighted_edges_from([(1, 7, 2), (1, 8, 3), (2, 3, 4), (2, 4, 5), (2, 5, 6),
                 (2, 8, 1), (3, 4, 5), (6, 1, 0), (6, 2, 11),
                 (6, 3, 15), (7, 2, 3), (7, 4, 9)])
        g = Graph(G.nodes, G.edges, layout="circular", layout_scale=3,
                  labels=True, vertex_config={7: {"fill_color": RED}},
                  edge_type=WeightedLine,
                  edge_config= {(u, v): G.get_edge_data(u, v) for u, v in G.edges},
        )
        self.add(g)
```

and we get

![NetworkX Graph](examples/examples_assets/NetworkXGraph_ManimCE_v0.17.3.png)

## Take a look at the examples

Inside the examples folder, you can find some examples of how to use the plugin with different types of graphs, both undirected and directed. You can see how to configure different options for the weight label and the background. Check them out!



https://github.com/mutable-learning/manim-weighted-line/assets/112732721/92efecf1-097f-4431-aa12-d1f7030abe36

https://github.com/mutable-learning/manim-weighted-line/assets/112732721/70c08377-817d-4a93-b2f7-2b5d94e52bae

https://github.com/mutable-learning/manim-weighted-line/assets/112732721/54ce7490-a04e-4842-9c4f-4c35e83d128e


## How to contact
You can open issues and pull requests, but if you want to contact me directly you can go to:
- Email: MutableLearning@gmail.com
- YouTube: https://www.youtube.com/channel/UCMq14ztdWTLvhCR2j4h_3zA

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mutable-learning/manim-weighted-line",
    "name": "manim-weighted-line",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<3.12",
    "maintainer_email": "",
    "keywords": "manim,plugins",
    "author": "MutableLearning",
    "author_email": "mutable.learning@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0a/3b/853e20c7754107b425b71572504f84b5c1c89d4e40621fa26efb55a8cf8f/manim_weighted_line-0.1.0.tar.gz",
    "platform": null,
    "description": "# Manim Weighted Line\nA plugin for creating weighted network graphs in Manim\n\n## Table of contents:\n- [Manim Weighted Line](#manim-weighted-line)\n  - [Table of contents:](#table-of-contents)\n  - [Installation.](#installation)\n  - [What does Manim-Weighted-Line do?](#what-does-manim-weighted-line-do)\n  - [How do I use Manim-Weighted-Line?](#how-do-i-use-manim-weighted-line)\n  - [Take a look at the examples](#take-a-look-at-the-examples)\n  - [How to contact](#how-to-contact)\n\n## Installation.\n\nYou can install via pip:\n\n```\npip install manim-weighted-line\n```\n\nYou can also clone the repo and install it from here:\n\n```\ngit clone https://github.com/mutable-learning/manim-weighted-line.git\ncd manim-weighted-line\npython -m pip install .\n```\n\nor\n\n```\ngit clone https://github.com/mutable-learning/manim-weighted-line.git\ncd manim-weighted-line \npython -m pip install -e .\n```\n\n\n## What does Manim-Weighted-Line do?\nThis is a simple plugin that is designed to meet the needs of manim users who want to\n create weighted network graphs in Manim. There is no easy way to add weightings to\n the edges of graphs in Manim, so this plugin provides a simple solution for both \n undirected and directed graphs.\n\n## How do I use Manim-Weighted-Line?\nAfter installing the plugin, you can start using it by running:\n\n\n```\nfrom manim import *\nfrom manim_weighted_line import *\n\n```\nfor example\n\n```\nfrom manim import *\nfrom manim_weighted_line import *\n\nclass SimpleExample(Scene):\n    def construct(self):\n        weighted_line = WeightedLine(\n            0,\n            1,\n            weight=4,\n        )\n        self.add(weighted_line)\n```\nand we get\n\n![Simple Example](examples/examples_assets/SimpleExample_ManimCE_v0.17.3.png)\n\nTo use this line in your graphs, pass the configuration to the edge object and use the WeightedLine as the edge_type.\n\n```\nfrom manim import *\nfrom manim_weighted_line import *\n\nclass WeightedGraph(Scene):\n    def construct(self):\n        vertices = [1, 2, 3, 4, 5, 6, 7, 8]\n        edges = [(1, 7), (1, 8), (2, 3), (2, 4), (2, 5),\n                 (2, 8), (3, 4), (6, 1), (6, 2),\n                 (6, 3), (7, 2), (7, 4)]\n        g = DiGraph(vertices, edges, layout=\"circular\", layout_scale=3,\n                  labels=True, vertex_config={7: {\"fill_color\": RED}},\n                  edge_type=WeightedLine,\n                  edge_config={(1, 7): {\"stroke_color\": RED, 'weight': 2},\n                               (7, 2): {\"stroke_color\": RED, 'weight': 0},\n                               (7, 4): {\"stroke_color\": RED, 'weight': 5}})\n        self.add(g)\n```\n\nand we get\n\n![Weighted Graph](examples/examples_assets/WeightedGraph_ManimCE_v0.17.3.png)\n\nIf you are using NetworkX to create your graph, you can use the WeightedLine as the edge_type and pass it config options in the edge_config dictionary:\n\n```\nfrom manim import *\nfrom manim_weighted_line import *\nimport networkx as nx\n\nclass NetworkXGraph(Scene):\n    def construct(self):\n        G = nx.Graph()\n        G.add_nodes_from([1, 2, 3, 4, 5, 6, 7, 8])\n        G.add_weighted_edges_from([(1, 7, 2), (1, 8, 3), (2, 3, 4), (2, 4, 5), (2, 5, 6),\n                 (2, 8, 1), (3, 4, 5), (6, 1, 0), (6, 2, 11),\n                 (6, 3, 15), (7, 2, 3), (7, 4, 9)])\n        g = Graph(G.nodes, G.edges, layout=\"circular\", layout_scale=3,\n                  labels=True, vertex_config={7: {\"fill_color\": RED}},\n                  edge_type=WeightedLine,\n                  edge_config= {(u, v): G.get_edge_data(u, v) for u, v in G.edges},\n        )\n        self.add(g)\n```\n\nand we get\n\n![NetworkX Graph](examples/examples_assets/NetworkXGraph_ManimCE_v0.17.3.png)\n\n## Take a look at the examples\n\nInside the examples folder, you can find some examples of how to use the plugin with different types of graphs, both undirected and directed. You can see how to configure different options for the weight label and the background. Check them out!\n\n\n\nhttps://github.com/mutable-learning/manim-weighted-line/assets/112732721/92efecf1-097f-4431-aa12-d1f7030abe36\n\nhttps://github.com/mutable-learning/manim-weighted-line/assets/112732721/70c08377-817d-4a93-b2f7-2b5d94e52bae\n\nhttps://github.com/mutable-learning/manim-weighted-line/assets/112732721/54ce7490-a04e-4842-9c4f-4c35e83d128e\n\n\n## How to contact\nYou can open issues and pull requests, but if you want to contact me directly you can go to:\n- Email: MutableLearning@gmail.com\n- YouTube: https://www.youtube.com/channel/UCMq14ztdWTLvhCR2j4h_3zA\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Adds a weighted line object to use with network graph diagrams.",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/mutable-learning/manim-weighted-line/issues",
        "Changelog": "https://github.com/mutable-learning/manim-weighted-line/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/mutable-learning/manim-weighted-line",
        "Repository": "https://github.com/mutable-learning/manim-weighted-line"
    },
    "split_keywords": [
        "manim",
        "plugins"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0f5be1e35a00d0b181e732d9d8faad19ca514f255282d449e5771d47ee42356a",
                "md5": "a795134022c76cebc7371fe29e50659f",
                "sha256": "5e92305064540f9be95a5c4e9e127eb861a27f4079453d44a766b4c98140beec"
            },
            "downloads": -1,
            "filename": "manim_weighted_line-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a795134022c76cebc7371fe29e50659f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<3.12",
            "size": 4986,
            "upload_time": "2023-07-17T10:12:49",
            "upload_time_iso_8601": "2023-07-17T10:12:49.543783Z",
            "url": "https://files.pythonhosted.org/packages/0f/5b/e1e35a00d0b181e732d9d8faad19ca514f255282d449e5771d47ee42356a/manim_weighted_line-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a3b853e20c7754107b425b71572504f84b5c1c89d4e40621fa26efb55a8cf8f",
                "md5": "403b2a3d3482c83d641bd11781b5ff98",
                "sha256": "2a28e830a8e86579d91039ffff845bc82975b480b9198022dbf158183b58dc9b"
            },
            "downloads": -1,
            "filename": "manim_weighted_line-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "403b2a3d3482c83d641bd11781b5ff98",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<3.12",
            "size": 4101,
            "upload_time": "2023-07-17T10:12:51",
            "upload_time_iso_8601": "2023-07-17T10:12:51.598460Z",
            "url": "https://files.pythonhosted.org/packages/0a/3b/853e20c7754107b425b71572504f84b5c1c89d4e40621fa26efb55a8cf8f/manim_weighted_line-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-17 10:12:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mutable-learning",
    "github_project": "manim-weighted-line",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "manim-weighted-line"
}
        
Elapsed time: 0.12424s