In this section, we show a further example on using virtual class attributes from the domain of graphs.
Quite incomplete
We should make displayable an orthogonal property of graph, men måske ikke nødvendig for eksemplet?
But Network should be completed
Beta book:
class Graph:
class Node:< ...
class Link:< ...
root: ref Node
connect:< ...
class DisplayableGraph: Graph
class DisplaySymbol:< ??
class DisplayLine:< ??
class Node ::< { dispSymbol: ref DisplaySymbol }
class Link ::< { dispLine: ref DisplayLine }
connect ::< ...
display:< ...
class TravelingSalesmanGraph: Graph
class Node ::< { name: ref text }
class Link ::< { distance: var integer }
connect ::< { ... }
Pipe graph
Internet: Nodes/Servere, links, …, kabler, WIFI
class Network: Graph
class Node::< what do we have in a node? Mapping: host -> link
-- receivePacket, sendPacket, ...
...
class Link::< -- capacity/speed of connection
...
Page 5.x: -- almost the same as TravelingSalesmanGraph above
class Graph:
class Node:<
firstEdge: ref Edge
insertEdgeTo(to: ref Node)-> ref Edge:
...
display:< ...
class Edge:<
from, to: ref Node
nextEdge: ref Edge;
deleteMe:<
display:<
inner(display)
class RoadAndCityGraph: Graph
class Node::<
cityName: ref String
...
display::
... name of the city
firstEdge.roadLength
class Edge::<
roadLength: var Integer
...
display::
... length of the road
from.cityName