using System.Collections.Generic;
public static void Main()
char [][] ss = new char [][] {new char[] {'a','b'}, new char[] {'a','e'}, new char[] {'a','c'} , new char[] {'b','e'} , new char[] {'b','d'}, new char[] {'c','b'} };
Dictionary<char,List<char>> graph = new Dictionary<char,List<char>>{
Dictionary<char,List<char>> dirctedGraph = new Dictionary<char,List<char>>();
foreach(char [] edge in ss){
if(!graph.ContainsKey(edge[0])){
graph.Add(edge[0], new List<char>());
graph[edge[0]].Add(edge[1]);
graph[edge[0]].Add(edge[1]);
if(!graph.ContainsKey(edge[1])){
graph.Add(edge[1], new List<char>());
graph[edge[1]].Add(edge[0]);
graph[edge[1]].Add(edge[0]);
foreach(char [] edge in ss){
if(!dirctedGraph.ContainsKey(edge[0])){
dirctedGraph.Add(edge[0], new List<char>());
dirctedGraph[edge[0]].Add(edge[1]);
dirctedGraph[edge[0]].Add(edge[1]);
public static void dfss(Dictionary<char,List<char>> graph,char source){
Stack<char> s = new Stack<char>();
Console.Out.WriteLine(current);
foreach(char neighbor in graph[current]){