Assignment 15 - Networks


Assignment 15 - Networks

 

Objective

 

Use overall knowledge of data structures to solve problems

 

Introduction

 

In programming you are often confronted with a choice of choosing the correct object, structure, or algorithm to solve a problem. Making the wrong choice often leads to inefficiencies that must be corrected later or a complete inability to solve the problem.  This is important enough that there are even guides to technical interviews that help you get ready for these types of questions ( see http://careerdrill.com/blog/coding-interview/choosing-the-right-data-structure-to-solve-problems/ ). 

 

Also common in programming is the use of Caffeine (  https://en.wikipedia.org/wiki/Caffeine )

 

 

Assignment

 

So you will get to have a little fun with this assignment. You will model a caffeine molecule as a graph and present that computer model. Edges that are single bonds should be presented with a weight of 1, with a double bond - they should have a weight of 2. 

 

Build your model as a Graph.  The graph should be able to print all of its Nodes with each adjacent node. You can have a print button or simply call it when the Graph is built.

 

Output:

H (C)  <- there will be 9 of these

C (N,H) <- there will be 3 of these

N (C, C, C) <- there are 3 of these

N (C, C) <- only one of these

etc....

etc...

for each element and combination of connected element

 

 

For added fun use the code at https://bl.ocks.org/mbostock/3037015  to make a graphical representation of the molecule. Special thanks to Amanda Krummel for modeling Caffeine using the graph associated with this block. While you are at it - take a look at blocks and see some of the things you will learn to do in the next class COP4813 http://cop4813eaglin.pbworks.com/w/page/34415594/FrontPage   (  https://bl.ocks.org/   )

 

var graph = {
  "nodes": [
    {"atom": "O", "size": 16},//
    {"atom": "C", "size": 12},//
    {"atom":"N", "size": 14},//
    {"atom": "C", "size": 12},//
    {"atom": "C", "size": 12},//
    {"atom": "C", "size": 12},//
    {"atom": "N", "size": 14},//
    {"atom": "C", "size": 12},//
    {"atom": "H", "size": 1},//
    {"atom": "H", "size": 1},//
    {"atom": "H", "size": 1},//
    {"atom": "N", "size": 14},//
    {"atom": "C", "size": 12},//
    {"atom": "H", "size": 1},//
    {"atom": "N", "size": 14},//
    {"atom": "C", "size": 12},//
    {"atom": "H", "size": 1},//
    {"atom": "H", "size": 1},//
    {"atom": "H", "size": 1},//
    {"atom": "C", "size": 12},//
    {"atom": "H", "size": 1},//
    {"atom": "H", "size": 1},//
    {"atom": "H", "size": 1},//
    {"atom": "O", "size": 16}//
  ],
  "links": [
    {"source": 0, "target": 1,  "bond": 2},//o to c
    {"source": 1, "target":2, "bond":1},//c to n
    {"source":1, "target":3, "bond":1},//c to c
    {"source":3, "target":4, "bond": 2},//c to c 
    {"source": 2, "target":5, "bond": 1},//first n to c
    {"source": 5, "target":6, "bond": 1},//c to second n
    {"source": 4, "target": 6, "bond": 1},//double bonded to n
    {"source": 6, "target": 7, "bond": 1},//second n to c
    {"source": 8, "target": 7,"bond":1 }, //h to c
    {"source": 9, "target": 7, "bond":1},
    {"source": 10, "target": 7, "bond": 1},
    {"source": 11, "target": 4, "bond": 1}, // C to third N
    {"source": 11, "target": 12, "bond": 2}, //third n to double c
    {"source": 12, "target": 13, "bond": 1}, //c to h
    {"source": 12, "target": 14, "bond": 1}, //c to n
    {"source": 14, "target": 3, "bond":1},//n to second c
    {"source": 14, "target": 15, "bond":1},// n to c
    {"source": 16, "target": 15, "bond":1},
    {"source": 17, "target": 15, "bond":1},
    {"source": 18, "target": 15, "bond":1}, //h3 to c
    {"source": 19, "target": 2, "bond": 1}, // first n to c
    {"source": 20, "target": 19, "bond": 1},
    {"source": 21, "target": 19, "bond": 1},
    {"source": 22, "target": 19, "bond": 1}, //h3 to c
    {"source": 23, "target": 5, "bond": 2}
 
  ]
};