Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70770 > unrolled thread
| Started by | varun7rs@gmail.com |
|---|---|
| First post | 2014-04-30 02:30 -0700 |
| Last post | 2014-05-02 02:33 -0700 |
| Articles | 6 — 3 participants |
Back to article view | Back to comp.lang.python
Designing a network in Python varun7rs@gmail.com - 2014-04-30 02:30 -0700
RE: Designing a network in Python "Joseph L. Casale" <jcasale@activenetwerx.com> - 2014-04-30 12:28 +0000
Re: Designing a network in Python varun7rs@gmail.com - 2014-04-30 07:57 -0700
Re: Designing a network in Python Mark H Harris <harrismh777@gmail.com> - 2014-04-30 10:03 -0500
RE: Designing a network in Python "Joseph L. Casale" <jcasale@activenetwerx.com> - 2014-04-30 18:38 +0000
Re: Designing a network in Python varun7rs@gmail.com - 2014-05-02 02:33 -0700
| From | varun7rs@gmail.com |
|---|---|
| Date | 2014-04-30 02:30 -0700 |
| Subject | Designing a network in Python |
| Message-ID | <8ab783e8-a36e-49e5-a329-2c4d98df8537@googlegroups.com> |
Hello Friends
I would like to design a network given the topology and the source I use is
http://sndlib.zib.de/home.action
I have managed to read most of the important data in the xml onto lists. Now, I have two lists, Source and Destination and I'd like to create bi-directional links between them. My code is as below. And moreover, I'd like to assign some kind of a bandwidth capacity to the links and similarly, storage and processing capacity to the nodes. So, I generated some random integers for them. I don't know how to proceed further to design the topology. I'd prefer to do the topology design in another .py file probably. I'd be glad if you guys could lend me a helping hand.
import sys
import xml.dom.minidom as dom
import string
#from xml.dom.minidom import getDOMimplementation
from xml.dom import minidom
from xml.dom.minidom import parse
import os
import random
class PHY_NODES:
def __init__(self, nodeID, x, y, capacity_proc, capacity_stor, capacity_switch):
self.nodeID = nodeID
self.x = x
self.y = y
self.linklist = []
self.capacity_proc = capacity_proc
self.capacity_stor = capacity_stor
self.capacity_switch = capacity_switch
class PHY_LINKS:
def __init__(self, linkID, source, destination, capacity_bdw):
self.linkID = linkID
self.source = source
self.destination = destination
self.capacity_bdw = capacity_bdw
# Reading Nodes
Read_Data = minidom.parse("germany50.xml")
nodelist = Read_Data.getElementsByTagName("node")
corenodes = []
for node in nodelist :
corenodes.append(node.getAttribute("id"))
nodeid = node.getAttribute("id")
xCoordinates = node.getElementsByTagName("x") [0]
yCoordinates = node.getElementsByTagName("y") [0]
proc = random.randint(20, 40)
stor = random.randint(40, 80)
switch = random.randint(60, 90)
nodeobj = PHY_NODES(nodeid, xCoordinates, yCoordinates, proc, stor, switch)
# Reading Links
linklist = Read_Data.getElementsByTagName("link")
links = []
sources = []
destinations = []
capacity_link = []
for link in linklist :
linkid = link.getAttribute("id")
Source = link.getElementsByTagName("source") [0]
Destination = link.getElementsByTagName("target") [0]
Capacity = link.getElementsByTagName("capacity") [0]
linkobj = PHY_LINKS(linkid, Source, Destination, Capacity)
sources.append(Source.firstChild.data)
destinations.append(Destination.firstChild.data)
capacity_link.append(Capacity.firstChild.data)
[toc] | [next] | [standalone]
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
|---|---|
| Date | 2014-04-30 12:28 +0000 |
| Message-ID | <mailman.9607.1398860993.18130.python-list@python.org> |
| In reply to | #70770 |
> I have managed to read most of the important data in the xml onto lists. > Now, I have two lists, Source and Destination and I'd like to create bi-directional > links between them. > And moreover, I'd like to assign some kind of a bandwidth capacity to the links and > similarly, storage and processing capacity to the nodes. I don't know anything about your use case or data really, but from the above I already know I would shove this all into a database, adding tables with relations and mining data based on relations becomes trivial. More importantly, it also then becomes easily extensible without refactoring as your requirements change. Just my opinion, jlc
[toc] | [prev] | [next] | [standalone]
| From | varun7rs@gmail.com |
|---|---|
| Date | 2014-04-30 07:57 -0700 |
| Message-ID | <6b386a23-ee11-46df-ade7-6cb235df4a18@googlegroups.com> |
| In reply to | #70775 |
I don't know how to do that stuff in python. Basically, I'm trying to pull certain data from the xml file like the node-name, source, destination and the capacity. Since, I am done with that part, I now want to have a link between source and destination and assign capacity to it. eg., [a,b,c,d,e] [l,m,n,o,p] [5,2,3,4,5] I need something like a - l: 5, b - m: 2,....I don't know how to describe this exactly but I hope this would give you a rough idea. After this, I put the stuff back into an xml but this time only there are more parameters and looks more detailed.... Like nodeID = Aachen...stor_capacity = 100, proc_capacity = 200, switch_capacity = 190...etc
[toc] | [prev] | [next] | [standalone]
| From | Mark H Harris <harrismh777@gmail.com> |
|---|---|
| Date | 2014-04-30 10:03 -0500 |
| Message-ID | <ljr3c0$nrs$1@speranza.aioe.org> |
| In reply to | #70780 |
On 4/30/14 9:57 AM, varun7rs@gmail.com wrote:
> I don't know how to do that stuff in python.
Always a good time to learn.
Let the database do the work for you; try not to re-invent the
relational database wheel. Access the database via python-sql:
https://pypi.python.org/pypi/python-sql/
marcus
[toc] | [prev] | [next] | [standalone]
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
|---|---|
| Date | 2014-04-30 18:38 +0000 |
| Message-ID | <mailman.9613.1398883102.18130.python-list@python.org> |
| In reply to | #70780 |
> I don't know how to do that stuff in python. Basically, I'm trying to pull certain data from the > xml file like the node-name, source, destination and the capacity. Since, I am done with that > part, I now want to have a link between source and destination and assign capacity to it. I dont mind writing you an SQLite schema and accessor class, can you define your data in a tabular format and mail it to me offline, we add relationships etc as we go. Hopefully it inspires you to adopt this approach in the future as it often proves powerful. jlc
[toc] | [prev] | [next] | [standalone]
| From | varun7rs@gmail.com |
|---|---|
| Date | 2014-05-02 02:33 -0700 |
| Message-ID | <c8103c1c-4fc3-4442-b6f3-ab39733cbf30@googlegroups.com> |
| In reply to | #70788 |
On Wednesday, 30 April 2014 20:38:07 UTC+2, Joseph L. Casale wrote: > > I don't know how to do that stuff in python. Basically, I'm trying to pull certain data from the > > xml file like the node-name, source, destination and the capacity. Since, I am done with that > > part, I now want to have a link between source and destination and assign capacity to it. > > I dont mind writing you an SQLite schema and accessor class, can you define your data in a tabular > format and mail it to me offline, we add relationships etc as we go. > > Hopefully it inspires you to adopt this approach in the future as it often proves powerful. > > jlc Thanks a lot for your help. But, how do I mail you? I can't find your mail id here
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web