Implement Scheme Haskell Prolog Problem Directed Graph Implemented List Whose Elements Pai Q37244675

Implement in Scheme OR Haskell OR Prolog

Problem: A directed graph can be implemented as a list whoseelements are pairs of nodes. assume the nodes are integers. InHaskell, you can defined a graph as follows:

type Node = Integer

type edge = (Integer, Integer)

type Graph = [Edge]

type Path = [Node]

g :: Graph

g = [(1,2),(1,3), (2,3),(2,4),(3,4)]

h :: Graph

h = [(1,2),(1,3),(2,1),(3,2),(4,4)]

1. Write a function names nodes to get the list of nodes(increasing) of a graph. For example, nodes g => [1,2,3,4]

2. Write a function named adjacent that takes a node N and agraph G and returns a list of all nodes that are connected to

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.