# Path: autonetkit/design/utils/graph_utils.py
# def force_layout(topology: 'Topology', scale: int = 500):
#     """
# 
#     @param topology:
#     @param scale:
#     @return:
#     """
#     # note applies to global layout, but based on connectivity of provided topology
#     try:
#         import numpy
#     except ImportError:
#         logger.warning("Layout requires numpy to be installed")
#         return
#     graph = topology_to_nx_graph(topology)
#     print(graph)
#     center = [scale / 2, scale / 2]
#     pos = nx.spring_layout(graph, center=center, scale=scale)
#     for node_id, (x, y) in pos.items():
#         node = topology.get_node_by_id(node_id)
#         node.set("x", x)
#         node.set("y", y)
# 
#     normalise_node_locations(topology)
# 
# Path: autonetkit/load/common.py
# def build_model_from_nx_graph(graph: typing.Union[nx.Graph, nx.DiGraph]) -> NetworkModel:
#     """
# 
#     @param graph:
#     @return: 
#     """
#     raw_topology = {"nodes": [], "links": []}
#     for nid in graph.nodes():
#         raw_topology["nodes"].append({
#             "id": nid,
#             "label": f"r{nid}"
#         })
# 
#     for src, dst in graph.edges():
#         pair = (f"r{src}", f"r{dst}")
#         raw_topology["links"].append(pair)
# 
#     simplified_topology = SimplifiedTopology(**raw_topology)
#     topology = transform_simplified_to_structured_topology(simplified_topology)
#     network_model = process_structured_topology(topology)
# 
#     return network_model
# 
# Path: autonetkit/workflow/workflow.py
# class BaseWorkflow:
#     """
# 
#     """
# 
#     def __init__(self):
#         pass
# 
#     def run(self, network_model: NetworkModel, target_platform: str):
#         """
# 
#         @param network_model:
#         @param target_platform:
#         """
#         t_in = network_model.get_topology("input")
#         validate(t_in)
#         self.build(network_model)
#         self.render(network_model, target_platform)
#         self.publish(network_model)
# 
#     @staticmethod
#     def load(input_file):
#         """
# 
#         @param input_file:
#         @return:
#         """
#         network_model = import_from_graphml(input_file)
#         return network_model
# 
#     @staticmethod
#     def publish(network_model):
#         """
# 
#         @param network_model:
#         """
#         host = "http://0.0.0.0:8080"
#         publish_model_to_webserver(network_model, host)
# 
#     @staticmethod
#     def build(network_model):
#         """
# 
#         @param network_model:
#         """
#         builder = Builder(network_model)
#         builder.build()
# 
#     @staticmethod
#     def render(network_model, target_platform):
#         """
# 
#         @param network_model:
#         @param target_platform:
#         """
#         builder = get_platform_builder(target_platform)
#         builder.build(network_model)


from autonetkit.design.utils.graph_utils import force_layout
from autonetkit.load.common import build_model_from_nx_graph
from autonetkit.workflow.workflow import BaseWorkflow
    import networkx as nx


def main():
    """

    """
    workflow = BaseWorkflow()

    graph = nx.random_internet_as_graph(100)
    network_model = build_model_from_nx_graph(graph)
    t_in = network_model.get_topology("input")

    asn = 1
    for node_id, data in graph.nodes(data=True):
        node = t_in.get_node_by_id(str(node_id))
        node.set("role", data["type"])
        node.set("asn", asn)
        asn += 1

    t_in = network_model.get_topology("input")

# Path: autonetkit/design/utils/graph_utils.py
# def force_layout(topology: 'Topology', scale: int = 500):
#     """
# 
#     @param topology:
#     @param scale:
#     @return:
#     """
#     # note applies to global layout, but based on connectivity of provided topology
#     try:
#         import numpy
#     except ImportError:
#         logger.warning("Layout requires numpy to be installed")
#         return
#     graph = topology_to_nx_graph(topology)
#     print(graph)
#     center = [scale / 2, scale / 2]
#     pos = nx.spring_layout(graph, center=center, scale=scale)
#     for node_id, (x, y) in pos.items():
#         node = topology.get_node_by_id(node_id)
#         node.set("x", x)
#         node.set("y", y)
# 
#     normalise_node_locations(topology)
# 
# Path: autonetkit/load/common.py
# def build_model_from_nx_graph(graph: typing.Union[nx.Graph, nx.DiGraph]) -> NetworkModel:
#     """
# 
#     @param graph:
#     @return: 
#     """
#     raw_topology = {"nodes": [], "links": []}
#     for nid in graph.nodes():
#         raw_topology["nodes"].append({
#             "id": nid,
#             "label": f"r{nid}"
#         })
# 
#     for src, dst in graph.edges():
#         pair = (f"r{src}", f"r{dst}")
#         raw_topology["links"].append(pair)
# 
#     simplified_topology = SimplifiedTopology(**raw_topology)
#     topology = transform_simplified_to_structured_topology(simplified_topology)
#     network_model = process_structured_topology(topology)
# 
#     return network_model
# 
# Path: autonetkit/workflow/workflow.py
# class BaseWorkflow:
#     """
# 
#     """
# 
#     def __init__(self):
#         pass
# 
#     def run(self, network_model: NetworkModel, target_platform: str):
#         """
# 
#         @param network_model:
#         @param target_platform:
#         """
#         t_in = network_model.get_topology("input")
#         validate(t_in)
#         self.build(network_model)
#         self.render(network_model, target_platform)
#         self.publish(network_model)
# 
#     @staticmethod
#     def load(input_file):
#         """
# 
#         @param input_file:
#         @return:
#         """
#         network_model = import_from_graphml(input_file)
#         return network_model
# 
#     @staticmethod
#     def publish(network_model):
#         """
# 
#         @param network_model:
#         """
#         host = "http://0.0.0.0:8080"
#         publish_model_to_webserver(network_model, host)
# 
#     @staticmethod
#     def build(network_model):
#         """
# 
#         @param network_model:
#         """
#         builder = Builder(network_model)
#         builder.build()
# 
#     @staticmethod
#     def render(network_model, target_platform):
#         """
# 
#         @param network_model:
#         @param target_platform:
#         """
#         builder = get_platform_builder(target_platform)
#         builder.build(network_model)


# Path: autonetkit/tutorial/as_graph.py
from autonetkit.design.utils.graph_utils import force_layout
from autonetkit.load.common import build_model_from_nx_graph
from autonetkit.workflow.workflow import BaseWorkflow
    import networkx as nx



def main():
    """

    """
    workflow = BaseWorkflow()

    graph = nx.random_internet_as_graph(100)
    network_model = build_model_from_nx_graph(graph)
    t_in = network_model.get_topology("input")

    asn = 1
    for node_id, data in graph.nodes(data=True):
        node = t_in.get_node_by_id(str(node_id))
        node.set("role", data["type"])
        node.set("asn", asn)
        asn += 1

    t_in = network_model.get_topology("input")

    force_layout(t_in, scale=500)